
obj/net/testoutput:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 ff 02 00 00       	call   800330 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800040 <umain>:
static struct jif_pkt *pkt = (struct jif_pkt*)REQVA;


void
umain(void)
{
  800040:	55                   	push   %ebp
  800041:	89 e5                	mov    %esp,%ebp
  800043:	53                   	push   %ebx
  800044:	83 ec 14             	sub    $0x14,%esp
	envid_t ns_envid = sys_getenvid();
  800047:	e8 cd 12 00 00       	call   801319 <sys_getenvid>
  80004c:	89 c3                	mov    %eax,%ebx
	int i, r;

	binaryname = "testoutput";
  80004e:	c7 05 00 70 80 00 60 	movl   $0x802f60,0x807000
  800055:	2f 80 00 

	output_envid = fork();
  800058:	e8 75 13 00 00       	call   8013d2 <fork>
  80005d:	a3 74 70 80 00       	mov    %eax,0x807074
	if (output_envid < 0)
  800062:	85 c0                	test   %eax,%eax
  800064:	79 1c                	jns    800082 <umain+0x42>
		panic("error forking");
  800066:	c7 44 24 08 6b 2f 80 	movl   $0x802f6b,0x8(%esp)
  80006d:	00 
  80006e:	c7 44 24 04 16 00 00 	movl   $0x16,0x4(%esp)
  800075:	00 
  800076:	c7 04 24 79 2f 80 00 	movl   $0x802f79,(%esp)
  80007d:	e8 1a 03 00 00       	call   80039c <_panic>
	else if (output_envid == 0) {
  800082:	85 c0                	test   %eax,%eax
  800084:	75 0f                	jne    800095 <umain+0x55>
		output(ns_envid);
  800086:	89 1c 24             	mov    %ebx,(%esp)
  800089:	e8 3a 02 00 00       	call   8002c8 <output>
		return;
  80008e:	66 90                	xchg   %ax,%ax
  800090:	e9 de 00 00 00       	jmp    800173 <umain+0x133>
	}
    cprintf("Sending from Env: %x\n", ns_envid);
  800095:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800099:	c7 04 24 8a 2f 80 00 	movl   $0x802f8a,(%esp)
  8000a0:	e8 bc 03 00 00       	call   800461 <cprintf>
  8000a5:	bb 00 00 00 00       	mov    $0x0,%ebx

	for (i = 0; i < TESTOUTPUT_COUNT; i++) {
		if ((r = sys_page_alloc(0, pkt, PTE_P|PTE_U|PTE_W)) < 0)
  8000aa:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8000b1:	00 
  8000b2:	c7 44 24 04 00 b0 fe 	movl   $0xffeb000,0x4(%esp)
  8000b9:	0f 
  8000ba:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8000c1:	e8 c0 11 00 00       	call   801286 <sys_page_alloc>
  8000c6:	85 c0                	test   %eax,%eax
  8000c8:	79 20                	jns    8000ea <umain+0xaa>
			panic("sys_page_alloc: %e", r);
  8000ca:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8000ce:	c7 44 24 08 a0 2f 80 	movl   $0x802fa0,0x8(%esp)
  8000d5:	00 
  8000d6:	c7 44 24 04 1f 00 00 	movl   $0x1f,0x4(%esp)
  8000dd:	00 
  8000de:	c7 04 24 79 2f 80 00 	movl   $0x802f79,(%esp)
  8000e5:	e8 b2 02 00 00       	call   80039c <_panic>
		pkt->jp_len = snprintf(pkt->jp_data,
  8000ea:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8000ee:	c7 44 24 08 b3 2f 80 	movl   $0x802fb3,0x8(%esp)
  8000f5:	00 
  8000f6:	c7 44 24 04 fc 0f 00 	movl   $0xffc,0x4(%esp)
  8000fd:	00 
  8000fe:	c7 04 24 04 b0 fe 0f 	movl   $0xffeb004,(%esp)
  800105:	e8 7f 09 00 00       	call   800a89 <snprintf>
  80010a:	a3 00 b0 fe 0f       	mov    %eax,0xffeb000
				       PGSIZE - sizeof(pkt->jp_len),
				       "Packet %02d", i);
		cprintf("Transmitting packet %d\n", i);
  80010f:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800113:	c7 04 24 bf 2f 80 00 	movl   $0x802fbf,(%esp)
  80011a:	e8 42 03 00 00       	call   800461 <cprintf>
		ipc_send(output_envid, NSREQ_OUTPUT, pkt, PTE_P|PTE_W|PTE_U);
  80011f:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  800126:	00 
  800127:	c7 44 24 08 00 b0 fe 	movl   $0xffeb000,0x8(%esp)
  80012e:	0f 
  80012f:	c7 44 24 04 0b 00 00 	movl   $0xb,0x4(%esp)
  800136:	00 
  800137:	a1 74 70 80 00       	mov    0x807074,%eax
  80013c:	89 04 24             	mov    %eax,(%esp)
  80013f:	e8 6c 16 00 00       	call   8017b0 <ipc_send>
		sys_page_unmap(0, pkt);
  800144:	c7 44 24 04 00 b0 fe 	movl   $0xffeb000,0x4(%esp)
  80014b:	0f 
  80014c:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800153:	e8 72 10 00 00       	call   8011ca <sys_page_unmap>
		output(ns_envid);
		return;
	}
    cprintf("Sending from Env: %x\n", ns_envid);

	for (i = 0; i < TESTOUTPUT_COUNT; i++) {
  800158:	83 c3 01             	add    $0x1,%ebx
  80015b:	83 fb 0a             	cmp    $0xa,%ebx
  80015e:	0f 85 46 ff ff ff    	jne    8000aa <umain+0x6a>
  800164:	b3 00                	mov    $0x0,%bl
		sys_page_unmap(0, pkt);
	}

	// Spin for a while, just in case IPC's or packets need to be flushed
	for (i = 0; i < TESTOUTPUT_COUNT*2; i++)
		sys_yield();
  800166:	e8 7a 11 00 00       	call   8012e5 <sys_yield>
		ipc_send(output_envid, NSREQ_OUTPUT, pkt, PTE_P|PTE_W|PTE_U);
		sys_page_unmap(0, pkt);
	}

	// Spin for a while, just in case IPC's or packets need to be flushed
	for (i = 0; i < TESTOUTPUT_COUNT*2; i++)
  80016b:	83 c3 01             	add    $0x1,%ebx
  80016e:	83 fb 14             	cmp    $0x14,%ebx
  800171:	75 f3                	jne    800166 <umain+0x126>
		sys_yield();
}
  800173:	83 c4 14             	add    $0x14,%esp
  800176:	5b                   	pop    %ebx
  800177:	5d                   	pop    %ebp
  800178:	c3                   	ret    
  800179:	00 00                	add    %al,(%eax)
  80017b:	00 00                	add    %al,(%eax)
  80017d:	00 00                	add    %al,(%eax)
	...

00800180 <timer>:
#include "ns.h"

void
timer(envid_t ns_envid, uint32_t initial_to) {
  800180:	55                   	push   %ebp
  800181:	89 e5                	mov    %esp,%ebp
  800183:	57                   	push   %edi
  800184:	56                   	push   %esi
  800185:	53                   	push   %ebx
  800186:	83 ec 2c             	sub    $0x2c,%esp
  800189:	8b 75 08             	mov    0x8(%ebp),%esi
	uint32_t stop = sys_time_msec() + initial_to;
  80018c:	e8 2e 0e 00 00       	call   800fbf <sys_time_msec>
  800191:	89 c3                	mov    %eax,%ebx
  800193:	03 5d 0c             	add    0xc(%ebp),%ebx

	binaryname = "ns_timer";
  800196:	c7 05 00 70 80 00 d7 	movl   $0x802fd7,0x807000
  80019d:	2f 80 00 

		ipc_send(ns_envid, NSREQ_TIMER, 0, 0);

		while (1) {
			uint32_t to, whom;
			to = ipc_recv((int32_t *) &whom, 0, 0);
  8001a0:	8d 7d e4             	lea    -0x1c(%ebp),%edi
  8001a3:	eb 05                	jmp    8001aa <timer+0x2a>

	binaryname = "ns_timer";

	while (1) {
		while(sys_time_msec() < stop) {
			sys_yield();
  8001a5:	e8 3b 11 00 00       	call   8012e5 <sys_yield>
	uint32_t stop = sys_time_msec() + initial_to;

	binaryname = "ns_timer";

	while (1) {
		while(sys_time_msec() < stop) {
  8001aa:	e8 10 0e 00 00       	call   800fbf <sys_time_msec>
  8001af:	39 c3                	cmp    %eax,%ebx
  8001b1:	77 f2                	ja     8001a5 <timer+0x25>
			sys_yield();
		}

		ipc_send(ns_envid, NSREQ_TIMER, 0, 0);
  8001b3:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8001ba:	00 
  8001bb:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8001c2:	00 
  8001c3:	c7 44 24 04 0c 00 00 	movl   $0xc,0x4(%esp)
  8001ca:	00 
  8001cb:	89 34 24             	mov    %esi,(%esp)
  8001ce:	e8 dd 15 00 00       	call   8017b0 <ipc_send>

		while (1) {
			uint32_t to, whom;
			to = ipc_recv((int32_t *) &whom, 0, 0);
  8001d3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8001da:	00 
  8001db:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8001e2:	00 
  8001e3:	89 3c 24             	mov    %edi,(%esp)
  8001e6:	e8 37 16 00 00       	call   801822 <ipc_recv>
  8001eb:	89 c3                	mov    %eax,%ebx

			if (whom != ns_envid) {
  8001ed:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8001f0:	39 c6                	cmp    %eax,%esi
  8001f2:	74 12                	je     800206 <timer+0x86>
				cprintf("NS TIMER: timer thread got IPC message from env %x not NS\n", whom);
  8001f4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001f8:	c7 04 24 e0 2f 80 00 	movl   $0x802fe0,(%esp)
  8001ff:	e8 5d 02 00 00       	call   800461 <cprintf>
				continue;
			}

			stop = sys_time_msec() + to;
			break;
		}
  800204:	eb cd                	jmp    8001d3 <timer+0x53>
			if (whom != ns_envid) {
				cprintf("NS TIMER: timer thread got IPC message from env %x not NS\n", whom);
				continue;
			}

			stop = sys_time_msec() + to;
  800206:	e8 b4 0d 00 00       	call   800fbf <sys_time_msec>
  80020b:	8d 1c 18             	lea    (%eax,%ebx,1),%ebx
  80020e:	66 90                	xchg   %ax,%ax
  800210:	eb 98                	jmp    8001aa <timer+0x2a>
	...

00800220 <input>:

extern union Nsipc nsipcbuf;

void
input(envid_t ns_envid)
{
  800220:	55                   	push   %ebp
  800221:	89 e5                	mov    %esp,%ebp
  800223:	56                   	push   %esi
  800224:	53                   	push   %ebx
  800225:	83 ec 10             	sub    $0x10,%esp
  800228:	8b 75 08             	mov    0x8(%ebp),%esi
    int r=0;
    int n=0;
	struct jif_pkt *pkt = (struct jif_pkt *)0x00100000;
    envid_t envid   = sys_getenvid();
  80022b:	e8 e9 10 00 00       	call   801319 <sys_getenvid>
	binaryname = "ns_input";
  800230:	c7 05 00 70 80 00 1b 	movl   $0x80301b,0x807000
  800237:	30 80 00 
	// 	- read a packet from the device driver
	//	- send it to the network server
	// Hint: When you IPC a page to the network server, it will be
	// reading from it for a while, so don't immediately receive
	// another packet in to the same physical page.
    if((r=sys_page_alloc(0, (void *)pkt, PTE_P|PTE_W|PTE_U))<0)
  80023a:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  800241:	00 
  800242:	c7 44 24 04 00 00 10 	movl   $0x100000,0x4(%esp)
  800249:	00 
  80024a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800251:	e8 30 10 00 00       	call   801286 <sys_page_alloc>
        panic("sys_page_map: error: %x\n", r);

    while (1) {
        if((n=sys_ns_recv(pkt->jp_data, PGSIZE-sizeof(struct jif_pkt)))>0) {
            if (n != 11) {
            pkt->jp_len = n;
  800256:	bb 00 00 10 00       	mov    $0x100000,%ebx
	// 	- read a packet from the device driver
	//	- send it to the network server
	// Hint: When you IPC a page to the network server, it will be
	// reading from it for a while, so don't immediately receive
	// another packet in to the same physical page.
    if((r=sys_page_alloc(0, (void *)pkt, PTE_P|PTE_W|PTE_U))<0)
  80025b:	85 c0                	test   %eax,%eax
  80025d:	79 20                	jns    80027f <input+0x5f>
        panic("sys_page_map: error: %x\n", r);
  80025f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800263:	c7 44 24 08 24 30 80 	movl   $0x803024,0x8(%esp)
  80026a:	00 
  80026b:	c7 44 24 04 15 00 00 	movl   $0x15,0x4(%esp)
  800272:	00 
  800273:	c7 04 24 3d 30 80 00 	movl   $0x80303d,(%esp)
  80027a:	e8 1d 01 00 00       	call   80039c <_panic>

    while (1) {
        if((n=sys_ns_recv(pkt->jp_data, PGSIZE-sizeof(struct jif_pkt)))>0) {
  80027f:	c7 44 24 04 fc 0f 00 	movl   $0xffc,0x4(%esp)
  800286:	00 
  800287:	c7 04 24 04 00 10 00 	movl   $0x100004,(%esp)
  80028e:	e8 c0 0c 00 00       	call   800f53 <sys_ns_recv>
  800293:	85 c0                	test   %eax,%eax
  800295:	7e 28                	jle    8002bf <input+0x9f>
            if (n != 11) {
  800297:	83 f8 0b             	cmp    $0xb,%eax
  80029a:	74 1e                	je     8002ba <input+0x9a>
            pkt->jp_len = n;
  80029c:	89 03                	mov    %eax,(%ebx)
            ipc_send(ns_envid, NSREQ_INPUT, (void *)pkt, PTE_P|PTE_W|PTE_U);
  80029e:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8002a5:	00 
  8002a6:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8002aa:	c7 44 24 04 0a 00 00 	movl   $0xa,0x4(%esp)
  8002b1:	00 
  8002b2:	89 34 24             	mov    %esi,(%esp)
  8002b5:	e8 f6 14 00 00       	call   8017b0 <ipc_send>
            }
            sys_yield();
  8002ba:	e8 26 10 00 00       	call   8012e5 <sys_yield>
        } 
        sys_yield();
  8002bf:	e8 21 10 00 00       	call   8012e5 <sys_yield>
    }
  8002c4:	eb b9                	jmp    80027f <input+0x5f>
	...

008002c8 <output>:

extern union Nsipc nsipcbuf;

void
output(envid_t ns_envid)
{
  8002c8:	55                   	push   %ebp
  8002c9:	89 e5                	mov    %esp,%ebp
  8002cb:	53                   	push   %ebx
  8002cc:	83 ec 24             	sub    $0x24,%esp
    int r=0;
    envid_t from=0;
  8002cf:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
	binaryname = "ns_output";
  8002d6:	c7 05 00 70 80 00 49 	movl   $0x803049,0x807000
  8002dd:	30 80 00 

	// LAB 6: Your code here:
	// 	- read a packet from the network server
	//	- send the packet to the device driver
    while(1) {
        if((r=ipc_recv(&from, &nsipcbuf.pkt, NULL))==NSREQ_OUTPUT) {
  8002e0:	8d 5d f4             	lea    -0xc(%ebp),%ebx
  8002e3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8002ea:	00 
  8002eb:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  8002f2:	00 
  8002f3:	89 1c 24             	mov    %ebx,(%esp)
  8002f6:	e8 27 15 00 00       	call   801822 <ipc_recv>
  8002fb:	83 f8 0b             	cmp    $0xb,%eax
  8002fe:	75 17                	jne    800317 <output+0x4f>
            //cprintf("\nBuffer: %s Len: %d From: %x nsid: %x", &nsipcbuf.pkt.jp_data, nsipcbuf.pkt.jp_len, from, ns_envid);
            //cprintf("\nSending to driver");
            r   = sys_ns_send(&nsipcbuf.pkt.jp_data, nsipcbuf.pkt.jp_len);
  800300:	a1 00 60 80 00       	mov    0x806000,%eax
  800305:	89 44 24 04          	mov    %eax,0x4(%esp)
  800309:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  800310:	e8 74 0c 00 00       	call   800f89 <sys_ns_send>
  800315:	eb cc                	jmp    8002e3 <output+0x1b>
        } else {
            cprintf("output: error %x\n", r);
  800317:	89 44 24 04          	mov    %eax,0x4(%esp)
  80031b:	c7 04 24 53 30 80 00 	movl   $0x803053,(%esp)
  800322:	e8 3a 01 00 00       	call   800461 <cprintf>
            sys_yield();
  800327:	e8 b9 0f 00 00       	call   8012e5 <sys_yield>
  80032c:	eb b5                	jmp    8002e3 <output+0x1b>
	...

00800330 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  800330:	55                   	push   %ebp
  800331:	89 e5                	mov    %esp,%ebp
  800333:	83 ec 18             	sub    $0x18,%esp
  800336:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800339:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80033c:	8b 75 08             	mov    0x8(%ebp),%esi
  80033f:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  800342:	e8 d2 0f 00 00       	call   801319 <sys_getenvid>
	env = &envs [ENVX(envid)];
  800347:	25 ff 03 00 00       	and    $0x3ff,%eax
  80034c:	6b c0 7c             	imul   $0x7c,%eax,%eax
  80034f:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800354:	a3 78 70 80 00       	mov    %eax,0x807078

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800359:	85 f6                	test   %esi,%esi
  80035b:	7e 07                	jle    800364 <libmain+0x34>
		binaryname = argv[0];
  80035d:	8b 03                	mov    (%ebx),%eax
  80035f:	a3 00 70 80 00       	mov    %eax,0x807000

	// call user main routine
	umain(argc, argv);
  800364:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800368:	89 34 24             	mov    %esi,(%esp)
  80036b:	e8 d0 fc ff ff       	call   800040 <umain>

	// exit gracefully
	exit();
  800370:	e8 0b 00 00 00       	call   800380 <exit>
}
  800375:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800378:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80037b:	89 ec                	mov    %ebp,%esp
  80037d:	5d                   	pop    %ebp
  80037e:	c3                   	ret    
	...

00800380 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800380:	55                   	push   %ebp
  800381:	89 e5                	mov    %esp,%ebp
  800383:	83 ec 18             	sub    $0x18,%esp
	close_all();
  800386:	e8 2e 1a 00 00       	call   801db9 <close_all>
	sys_env_destroy(0);
  80038b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800392:	e8 b6 0f 00 00       	call   80134d <sys_env_destroy>
}
  800397:	c9                   	leave  
  800398:	c3                   	ret    
  800399:	00 00                	add    %al,(%eax)
	...

0080039c <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  80039c:	55                   	push   %ebp
  80039d:	89 e5                	mov    %esp,%ebp
  80039f:	53                   	push   %ebx
  8003a0:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  8003a3:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  8003a6:	a1 7c 70 80 00       	mov    0x80707c,%eax
  8003ab:	85 c0                	test   %eax,%eax
  8003ad:	74 10                	je     8003bf <_panic+0x23>
		cprintf("%s: ", argv0);
  8003af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8003b3:	c7 04 24 7c 30 80 00 	movl   $0x80307c,(%esp)
  8003ba:	e8 a2 00 00 00       	call   800461 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  8003bf:	8b 45 0c             	mov    0xc(%ebp),%eax
  8003c2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8003c6:	8b 45 08             	mov    0x8(%ebp),%eax
  8003c9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8003cd:	a1 00 70 80 00       	mov    0x807000,%eax
  8003d2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8003d6:	c7 04 24 81 30 80 00 	movl   $0x803081,(%esp)
  8003dd:	e8 7f 00 00 00       	call   800461 <cprintf>
	vcprintf(fmt, ap);
  8003e2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8003e6:	8b 45 10             	mov    0x10(%ebp),%eax
  8003e9:	89 04 24             	mov    %eax,(%esp)
  8003ec:	e8 0f 00 00 00       	call   800400 <vcprintf>
	cprintf("\n");
  8003f1:	c7 04 24 07 34 80 00 	movl   $0x803407,(%esp)
  8003f8:	e8 64 00 00 00       	call   800461 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  8003fd:	cc                   	int3   
  8003fe:	eb fd                	jmp    8003fd <_panic+0x61>

00800400 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  800400:	55                   	push   %ebp
  800401:	89 e5                	mov    %esp,%ebp
  800403:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  800409:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800410:	00 00 00 
	b.cnt = 0;
  800413:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  80041a:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  80041d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800420:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800424:	8b 45 08             	mov    0x8(%ebp),%eax
  800427:	89 44 24 08          	mov    %eax,0x8(%esp)
  80042b:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800431:	89 44 24 04          	mov    %eax,0x4(%esp)
  800435:	c7 04 24 7b 04 80 00 	movl   $0x80047b,(%esp)
  80043c:	e8 cc 01 00 00       	call   80060d <vprintfmt>
	sys_cputs(b.buf, b.idx);
  800441:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  800447:	89 44 24 04          	mov    %eax,0x4(%esp)
  80044b:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800451:	89 04 24             	mov    %eax,(%esp)
  800454:	e8 c7 0a 00 00       	call   800f20 <sys_cputs>

	return b.cnt;
}
  800459:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  80045f:	c9                   	leave  
  800460:	c3                   	ret    

00800461 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800461:	55                   	push   %ebp
  800462:	89 e5                	mov    %esp,%ebp
  800464:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  800467:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  80046a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80046e:	8b 45 08             	mov    0x8(%ebp),%eax
  800471:	89 04 24             	mov    %eax,(%esp)
  800474:	e8 87 ff ff ff       	call   800400 <vcprintf>
	va_end(ap);

	return cnt;
}
  800479:	c9                   	leave  
  80047a:	c3                   	ret    

0080047b <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  80047b:	55                   	push   %ebp
  80047c:	89 e5                	mov    %esp,%ebp
  80047e:	53                   	push   %ebx
  80047f:	83 ec 14             	sub    $0x14,%esp
  800482:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800485:	8b 03                	mov    (%ebx),%eax
  800487:	8b 55 08             	mov    0x8(%ebp),%edx
  80048a:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  80048e:	83 c0 01             	add    $0x1,%eax
  800491:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  800493:	3d ff 00 00 00       	cmp    $0xff,%eax
  800498:	75 19                	jne    8004b3 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  80049a:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  8004a1:	00 
  8004a2:	8d 43 08             	lea    0x8(%ebx),%eax
  8004a5:	89 04 24             	mov    %eax,(%esp)
  8004a8:	e8 73 0a 00 00       	call   800f20 <sys_cputs>
		b->idx = 0;
  8004ad:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  8004b3:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  8004b7:	83 c4 14             	add    $0x14,%esp
  8004ba:	5b                   	pop    %ebx
  8004bb:	5d                   	pop    %ebp
  8004bc:	c3                   	ret    
  8004bd:	00 00                	add    %al,(%eax)
	...

008004c0 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  8004c0:	55                   	push   %ebp
  8004c1:	89 e5                	mov    %esp,%ebp
  8004c3:	57                   	push   %edi
  8004c4:	56                   	push   %esi
  8004c5:	53                   	push   %ebx
  8004c6:	83 ec 4c             	sub    $0x4c,%esp
  8004c9:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8004cc:	89 d6                	mov    %edx,%esi
  8004ce:	8b 45 08             	mov    0x8(%ebp),%eax
  8004d1:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8004d4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8004d7:	89 55 e0             	mov    %edx,-0x20(%ebp)
  8004da:	8b 45 10             	mov    0x10(%ebp),%eax
  8004dd:	8b 5d 14             	mov    0x14(%ebp),%ebx
  8004e0:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  8004e3:	89 45 dc             	mov    %eax,-0x24(%ebp)
  8004e6:	b9 00 00 00 00       	mov    $0x0,%ecx
  8004eb:	39 d1                	cmp    %edx,%ecx
  8004ed:	72 15                	jb     800504 <printnum+0x44>
  8004ef:	77 07                	ja     8004f8 <printnum+0x38>
  8004f1:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8004f4:	39 d0                	cmp    %edx,%eax
  8004f6:	76 0c                	jbe    800504 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8004f8:	83 eb 01             	sub    $0x1,%ebx
  8004fb:	85 db                	test   %ebx,%ebx
  8004fd:	8d 76 00             	lea    0x0(%esi),%esi
  800500:	7f 61                	jg     800563 <printnum+0xa3>
  800502:	eb 70                	jmp    800574 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800504:	89 7c 24 10          	mov    %edi,0x10(%esp)
  800508:	83 eb 01             	sub    $0x1,%ebx
  80050b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80050f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800513:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800517:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80051b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80051e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800521:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800524:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800528:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80052f:	00 
  800530:	8b 45 d8             	mov    -0x28(%ebp),%eax
  800533:	89 04 24             	mov    %eax,(%esp)
  800536:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800539:	89 54 24 04          	mov    %edx,0x4(%esp)
  80053d:	e8 ae 27 00 00       	call   802cf0 <__udivdi3>
  800542:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800545:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  800548:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80054c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800550:	89 04 24             	mov    %eax,(%esp)
  800553:	89 54 24 04          	mov    %edx,0x4(%esp)
  800557:	89 f2                	mov    %esi,%edx
  800559:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80055c:	e8 5f ff ff ff       	call   8004c0 <printnum>
  800561:	eb 11                	jmp    800574 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800563:	89 74 24 04          	mov    %esi,0x4(%esp)
  800567:	89 3c 24             	mov    %edi,(%esp)
  80056a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80056d:	83 eb 01             	sub    $0x1,%ebx
  800570:	85 db                	test   %ebx,%ebx
  800572:	7f ef                	jg     800563 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800574:	89 74 24 04          	mov    %esi,0x4(%esp)
  800578:	8b 74 24 04          	mov    0x4(%esp),%esi
  80057c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80057f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800583:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80058a:	00 
  80058b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80058e:	89 14 24             	mov    %edx,(%esp)
  800591:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800594:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800598:	e8 83 28 00 00       	call   802e20 <__umoddi3>
  80059d:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005a1:	0f be 80 9d 30 80 00 	movsbl 0x80309d(%eax),%eax
  8005a8:	89 04 24             	mov    %eax,(%esp)
  8005ab:	ff 55 e4             	call   *-0x1c(%ebp)
}
  8005ae:	83 c4 4c             	add    $0x4c,%esp
  8005b1:	5b                   	pop    %ebx
  8005b2:	5e                   	pop    %esi
  8005b3:	5f                   	pop    %edi
  8005b4:	5d                   	pop    %ebp
  8005b5:	c3                   	ret    

008005b6 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  8005b6:	55                   	push   %ebp
  8005b7:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  8005b9:	83 fa 01             	cmp    $0x1,%edx
  8005bc:	7e 0e                	jle    8005cc <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  8005be:	8b 10                	mov    (%eax),%edx
  8005c0:	8d 4a 08             	lea    0x8(%edx),%ecx
  8005c3:	89 08                	mov    %ecx,(%eax)
  8005c5:	8b 02                	mov    (%edx),%eax
  8005c7:	8b 52 04             	mov    0x4(%edx),%edx
  8005ca:	eb 22                	jmp    8005ee <getuint+0x38>
	else if (lflag)
  8005cc:	85 d2                	test   %edx,%edx
  8005ce:	74 10                	je     8005e0 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  8005d0:	8b 10                	mov    (%eax),%edx
  8005d2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8005d5:	89 08                	mov    %ecx,(%eax)
  8005d7:	8b 02                	mov    (%edx),%eax
  8005d9:	ba 00 00 00 00       	mov    $0x0,%edx
  8005de:	eb 0e                	jmp    8005ee <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  8005e0:	8b 10                	mov    (%eax),%edx
  8005e2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8005e5:	89 08                	mov    %ecx,(%eax)
  8005e7:	8b 02                	mov    (%edx),%eax
  8005e9:	ba 00 00 00 00       	mov    $0x0,%edx
}
  8005ee:	5d                   	pop    %ebp
  8005ef:	c3                   	ret    

008005f0 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  8005f0:	55                   	push   %ebp
  8005f1:	89 e5                	mov    %esp,%ebp
  8005f3:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  8005f6:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  8005fa:	8b 10                	mov    (%eax),%edx
  8005fc:	3b 50 04             	cmp    0x4(%eax),%edx
  8005ff:	73 0a                	jae    80060b <sprintputch+0x1b>
		*b->buf++ = ch;
  800601:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800604:	88 0a                	mov    %cl,(%edx)
  800606:	83 c2 01             	add    $0x1,%edx
  800609:	89 10                	mov    %edx,(%eax)
}
  80060b:	5d                   	pop    %ebp
  80060c:	c3                   	ret    

0080060d <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  80060d:	55                   	push   %ebp
  80060e:	89 e5                	mov    %esp,%ebp
  800610:	57                   	push   %edi
  800611:	56                   	push   %esi
  800612:	53                   	push   %ebx
  800613:	83 ec 5c             	sub    $0x5c,%esp
  800616:	8b 7d 08             	mov    0x8(%ebp),%edi
  800619:	8b 75 0c             	mov    0xc(%ebp),%esi
  80061c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80061f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800626:	eb 11                	jmp    800639 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800628:	85 c0                	test   %eax,%eax
  80062a:	0f 84 f9 03 00 00    	je     800a29 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  800630:	89 74 24 04          	mov    %esi,0x4(%esp)
  800634:	89 04 24             	mov    %eax,(%esp)
  800637:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  800639:	0f b6 03             	movzbl (%ebx),%eax
  80063c:	83 c3 01             	add    $0x1,%ebx
  80063f:	83 f8 25             	cmp    $0x25,%eax
  800642:	75 e4                	jne    800628 <vprintfmt+0x1b>
  800644:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  800648:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  80064f:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  800656:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  80065d:	b9 00 00 00 00       	mov    $0x0,%ecx
  800662:	eb 06                	jmp    80066a <vprintfmt+0x5d>
  800664:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800668:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80066a:	0f b6 13             	movzbl (%ebx),%edx
  80066d:	0f b6 c2             	movzbl %dl,%eax
  800670:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800673:	8d 43 01             	lea    0x1(%ebx),%eax
  800676:	83 ea 23             	sub    $0x23,%edx
  800679:	80 fa 55             	cmp    $0x55,%dl
  80067c:	0f 87 8a 03 00 00    	ja     800a0c <vprintfmt+0x3ff>
  800682:	0f b6 d2             	movzbl %dl,%edx
  800685:	ff 24 95 e0 31 80 00 	jmp    *0x8031e0(,%edx,4)
  80068c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800690:	eb d6                	jmp    800668 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800692:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800695:	83 ea 30             	sub    $0x30,%edx
  800698:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80069b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80069e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  8006a1:	83 fb 09             	cmp    $0x9,%ebx
  8006a4:	77 54                	ja     8006fa <vprintfmt+0xed>
  8006a6:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  8006a9:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  8006ac:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  8006af:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  8006b2:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  8006b6:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  8006b9:	8d 5a d0             	lea    -0x30(%edx),%ebx
  8006bc:	83 fb 09             	cmp    $0x9,%ebx
  8006bf:	76 eb                	jbe    8006ac <vprintfmt+0x9f>
  8006c1:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8006c4:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8006c7:	eb 31                	jmp    8006fa <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  8006c9:	8b 55 14             	mov    0x14(%ebp),%edx
  8006cc:	8d 5a 04             	lea    0x4(%edx),%ebx
  8006cf:	89 5d 14             	mov    %ebx,0x14(%ebp)
  8006d2:	8b 12                	mov    (%edx),%edx
  8006d4:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  8006d7:	eb 21                	jmp    8006fa <vprintfmt+0xed>

		case '.':
			if (width < 0)
  8006d9:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8006dd:	ba 00 00 00 00       	mov    $0x0,%edx
  8006e2:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  8006e6:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8006e9:	e9 7a ff ff ff       	jmp    800668 <vprintfmt+0x5b>
  8006ee:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  8006f5:	e9 6e ff ff ff       	jmp    800668 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  8006fa:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8006fe:	0f 89 64 ff ff ff    	jns    800668 <vprintfmt+0x5b>
  800704:	8b 55 d0             	mov    -0x30(%ebp),%edx
  800707:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80070a:	8b 55 c8             	mov    -0x38(%ebp),%edx
  80070d:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800710:	e9 53 ff ff ff       	jmp    800668 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800715:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800718:	e9 4b ff ff ff       	jmp    800668 <vprintfmt+0x5b>
  80071d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800720:	8b 45 14             	mov    0x14(%ebp),%eax
  800723:	8d 50 04             	lea    0x4(%eax),%edx
  800726:	89 55 14             	mov    %edx,0x14(%ebp)
  800729:	89 74 24 04          	mov    %esi,0x4(%esp)
  80072d:	8b 00                	mov    (%eax),%eax
  80072f:	89 04 24             	mov    %eax,(%esp)
  800732:	ff d7                	call   *%edi
  800734:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800737:	e9 fd fe ff ff       	jmp    800639 <vprintfmt+0x2c>
  80073c:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  80073f:	8b 45 14             	mov    0x14(%ebp),%eax
  800742:	8d 50 04             	lea    0x4(%eax),%edx
  800745:	89 55 14             	mov    %edx,0x14(%ebp)
  800748:	8b 00                	mov    (%eax),%eax
  80074a:	89 c2                	mov    %eax,%edx
  80074c:	c1 fa 1f             	sar    $0x1f,%edx
  80074f:	31 d0                	xor    %edx,%eax
  800751:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  800753:	83 f8 12             	cmp    $0x12,%eax
  800756:	7f 0b                	jg     800763 <vprintfmt+0x156>
  800758:	8b 14 85 40 33 80 00 	mov    0x803340(,%eax,4),%edx
  80075f:	85 d2                	test   %edx,%edx
  800761:	75 20                	jne    800783 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800763:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800767:	c7 44 24 08 ae 30 80 	movl   $0x8030ae,0x8(%esp)
  80076e:	00 
  80076f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800773:	89 3c 24             	mov    %edi,(%esp)
  800776:	e8 36 03 00 00       	call   800ab1 <printfmt>
  80077b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  80077e:	e9 b6 fe ff ff       	jmp    800639 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800783:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800787:	c7 44 24 08 82 36 80 	movl   $0x803682,0x8(%esp)
  80078e:	00 
  80078f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800793:	89 3c 24             	mov    %edi,(%esp)
  800796:	e8 16 03 00 00       	call   800ab1 <printfmt>
  80079b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80079e:	e9 96 fe ff ff       	jmp    800639 <vprintfmt+0x2c>
  8007a3:	89 45 cc             	mov    %eax,-0x34(%ebp)
  8007a6:	89 c3                	mov    %eax,%ebx
  8007a8:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8007ab:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8007ae:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  8007b1:	8b 45 14             	mov    0x14(%ebp),%eax
  8007b4:	8d 50 04             	lea    0x4(%eax),%edx
  8007b7:	89 55 14             	mov    %edx,0x14(%ebp)
  8007ba:	8b 00                	mov    (%eax),%eax
  8007bc:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8007bf:	85 c0                	test   %eax,%eax
  8007c1:	b8 b7 30 80 00       	mov    $0x8030b7,%eax
  8007c6:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  8007ca:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  8007cd:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  8007d1:	7e 06                	jle    8007d9 <vprintfmt+0x1cc>
  8007d3:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  8007d7:	75 13                	jne    8007ec <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8007d9:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8007dc:	0f be 02             	movsbl (%edx),%eax
  8007df:	85 c0                	test   %eax,%eax
  8007e1:	0f 85 9b 00 00 00    	jne    800882 <vprintfmt+0x275>
  8007e7:	e9 88 00 00 00       	jmp    800874 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8007ec:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  8007f0:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8007f3:	89 0c 24             	mov    %ecx,(%esp)
  8007f6:	e8 00 03 00 00       	call   800afb <strnlen>
  8007fb:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  8007fe:	29 c2                	sub    %eax,%edx
  800800:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800803:	85 d2                	test   %edx,%edx
  800805:	7e d2                	jle    8007d9 <vprintfmt+0x1cc>
					putch(padc, putdat);
  800807:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  80080b:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  80080e:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800811:	89 d3                	mov    %edx,%ebx
  800813:	89 74 24 04          	mov    %esi,0x4(%esp)
  800817:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80081a:	89 04 24             	mov    %eax,(%esp)
  80081d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80081f:	83 eb 01             	sub    $0x1,%ebx
  800822:	85 db                	test   %ebx,%ebx
  800824:	7f ed                	jg     800813 <vprintfmt+0x206>
  800826:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800829:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800830:	eb a7                	jmp    8007d9 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800832:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800836:	74 1a                	je     800852 <vprintfmt+0x245>
  800838:	8d 50 e0             	lea    -0x20(%eax),%edx
  80083b:	83 fa 5e             	cmp    $0x5e,%edx
  80083e:	76 12                	jbe    800852 <vprintfmt+0x245>
					putch('?', putdat);
  800840:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800844:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  80084b:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  80084e:	66 90                	xchg   %ax,%ax
  800850:	eb 0a                	jmp    80085c <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  800852:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800856:	89 04 24             	mov    %eax,(%esp)
  800859:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  80085c:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800860:	0f be 03             	movsbl (%ebx),%eax
  800863:	85 c0                	test   %eax,%eax
  800865:	74 05                	je     80086c <vprintfmt+0x25f>
  800867:	83 c3 01             	add    $0x1,%ebx
  80086a:	eb 29                	jmp    800895 <vprintfmt+0x288>
  80086c:	89 fe                	mov    %edi,%esi
  80086e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800871:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800874:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800878:	7f 2e                	jg     8008a8 <vprintfmt+0x29b>
  80087a:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80087d:	e9 b7 fd ff ff       	jmp    800639 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800882:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800885:	83 c2 01             	add    $0x1,%edx
  800888:	89 7d e0             	mov    %edi,-0x20(%ebp)
  80088b:	89 f7                	mov    %esi,%edi
  80088d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800890:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800893:	89 d3                	mov    %edx,%ebx
  800895:	85 f6                	test   %esi,%esi
  800897:	78 99                	js     800832 <vprintfmt+0x225>
  800899:	83 ee 01             	sub    $0x1,%esi
  80089c:	79 94                	jns    800832 <vprintfmt+0x225>
  80089e:	89 fe                	mov    %edi,%esi
  8008a0:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8008a3:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  8008a6:	eb cc                	jmp    800874 <vprintfmt+0x267>
  8008a8:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  8008ab:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  8008ae:	89 74 24 04          	mov    %esi,0x4(%esp)
  8008b2:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  8008b9:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8008bb:	83 eb 01             	sub    $0x1,%ebx
  8008be:	85 db                	test   %ebx,%ebx
  8008c0:	7f ec                	jg     8008ae <vprintfmt+0x2a1>
  8008c2:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  8008c5:	e9 6f fd ff ff       	jmp    800639 <vprintfmt+0x2c>
  8008ca:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  8008cd:	83 f9 01             	cmp    $0x1,%ecx
  8008d0:	7e 16                	jle    8008e8 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  8008d2:	8b 45 14             	mov    0x14(%ebp),%eax
  8008d5:	8d 50 08             	lea    0x8(%eax),%edx
  8008d8:	89 55 14             	mov    %edx,0x14(%ebp)
  8008db:	8b 10                	mov    (%eax),%edx
  8008dd:	8b 48 04             	mov    0x4(%eax),%ecx
  8008e0:	89 55 d8             	mov    %edx,-0x28(%ebp)
  8008e3:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8008e6:	eb 32                	jmp    80091a <vprintfmt+0x30d>
	else if (lflag)
  8008e8:	85 c9                	test   %ecx,%ecx
  8008ea:	74 18                	je     800904 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  8008ec:	8b 45 14             	mov    0x14(%ebp),%eax
  8008ef:	8d 50 04             	lea    0x4(%eax),%edx
  8008f2:	89 55 14             	mov    %edx,0x14(%ebp)
  8008f5:	8b 00                	mov    (%eax),%eax
  8008f7:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8008fa:	89 c1                	mov    %eax,%ecx
  8008fc:	c1 f9 1f             	sar    $0x1f,%ecx
  8008ff:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800902:	eb 16                	jmp    80091a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  800904:	8b 45 14             	mov    0x14(%ebp),%eax
  800907:	8d 50 04             	lea    0x4(%eax),%edx
  80090a:	89 55 14             	mov    %edx,0x14(%ebp)
  80090d:	8b 00                	mov    (%eax),%eax
  80090f:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800912:	89 c2                	mov    %eax,%edx
  800914:	c1 fa 1f             	sar    $0x1f,%edx
  800917:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80091a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80091d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800920:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800925:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800929:	0f 89 9b 00 00 00    	jns    8009ca <vprintfmt+0x3bd>
				putch('-', putdat);
  80092f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800933:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  80093a:	ff d7                	call   *%edi
				num = -(long long) num;
  80093c:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80093f:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800942:	f7 d9                	neg    %ecx
  800944:	83 d3 00             	adc    $0x0,%ebx
  800947:	f7 db                	neg    %ebx
  800949:	b8 0a 00 00 00       	mov    $0xa,%eax
  80094e:	eb 7a                	jmp    8009ca <vprintfmt+0x3bd>
  800950:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  800953:	89 ca                	mov    %ecx,%edx
  800955:	8d 45 14             	lea    0x14(%ebp),%eax
  800958:	e8 59 fc ff ff       	call   8005b6 <getuint>
  80095d:	89 c1                	mov    %eax,%ecx
  80095f:	89 d3                	mov    %edx,%ebx
  800961:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800966:	eb 62                	jmp    8009ca <vprintfmt+0x3bd>
  800968:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  80096b:	89 ca                	mov    %ecx,%edx
  80096d:	8d 45 14             	lea    0x14(%ebp),%eax
  800970:	e8 41 fc ff ff       	call   8005b6 <getuint>
  800975:	89 c1                	mov    %eax,%ecx
  800977:	89 d3                	mov    %edx,%ebx
  800979:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  80097e:	eb 4a                	jmp    8009ca <vprintfmt+0x3bd>
  800980:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  800983:	89 74 24 04          	mov    %esi,0x4(%esp)
  800987:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  80098e:	ff d7                	call   *%edi
			putch('x', putdat);
  800990:	89 74 24 04          	mov    %esi,0x4(%esp)
  800994:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80099b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80099d:	8b 45 14             	mov    0x14(%ebp),%eax
  8009a0:	8d 50 04             	lea    0x4(%eax),%edx
  8009a3:	89 55 14             	mov    %edx,0x14(%ebp)
  8009a6:	8b 08                	mov    (%eax),%ecx
  8009a8:	bb 00 00 00 00       	mov    $0x0,%ebx
  8009ad:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  8009b2:	eb 16                	jmp    8009ca <vprintfmt+0x3bd>
  8009b4:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  8009b7:	89 ca                	mov    %ecx,%edx
  8009b9:	8d 45 14             	lea    0x14(%ebp),%eax
  8009bc:	e8 f5 fb ff ff       	call   8005b6 <getuint>
  8009c1:	89 c1                	mov    %eax,%ecx
  8009c3:	89 d3                	mov    %edx,%ebx
  8009c5:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  8009ca:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  8009ce:	89 54 24 10          	mov    %edx,0x10(%esp)
  8009d2:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8009d5:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8009d9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8009dd:	89 0c 24             	mov    %ecx,(%esp)
  8009e0:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8009e4:	89 f2                	mov    %esi,%edx
  8009e6:	89 f8                	mov    %edi,%eax
  8009e8:	e8 d3 fa ff ff       	call   8004c0 <printnum>
  8009ed:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8009f0:	e9 44 fc ff ff       	jmp    800639 <vprintfmt+0x2c>
  8009f5:	89 45 cc             	mov    %eax,-0x34(%ebp)
  8009f8:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  8009fb:	89 74 24 04          	mov    %esi,0x4(%esp)
  8009ff:	89 14 24             	mov    %edx,(%esp)
  800a02:	ff d7                	call   *%edi
  800a04:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800a07:	e9 2d fc ff ff       	jmp    800639 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  800a0c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a10:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800a17:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800a19:	8d 43 ff             	lea    -0x1(%ebx),%eax
  800a1c:	80 38 25             	cmpb   $0x25,(%eax)
  800a1f:	0f 84 14 fc ff ff    	je     800639 <vprintfmt+0x2c>
  800a25:	89 c3                	mov    %eax,%ebx
  800a27:	eb f0                	jmp    800a19 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800a29:	83 c4 5c             	add    $0x5c,%esp
  800a2c:	5b                   	pop    %ebx
  800a2d:	5e                   	pop    %esi
  800a2e:	5f                   	pop    %edi
  800a2f:	5d                   	pop    %ebp
  800a30:	c3                   	ret    

00800a31 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800a31:	55                   	push   %ebp
  800a32:	89 e5                	mov    %esp,%ebp
  800a34:	83 ec 28             	sub    $0x28,%esp
  800a37:	8b 45 08             	mov    0x8(%ebp),%eax
  800a3a:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  800a3d:	85 c0                	test   %eax,%eax
  800a3f:	74 04                	je     800a45 <vsnprintf+0x14>
  800a41:	85 d2                	test   %edx,%edx
  800a43:	7f 07                	jg     800a4c <vsnprintf+0x1b>
  800a45:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  800a4a:	eb 3b                	jmp    800a87 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  800a4c:	89 45 ec             	mov    %eax,-0x14(%ebp)
  800a4f:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  800a53:	89 45 f0             	mov    %eax,-0x10(%ebp)
  800a56:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  800a5d:	8b 45 14             	mov    0x14(%ebp),%eax
  800a60:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800a64:	8b 45 10             	mov    0x10(%ebp),%eax
  800a67:	89 44 24 08          	mov    %eax,0x8(%esp)
  800a6b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800a6e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800a72:	c7 04 24 f0 05 80 00 	movl   $0x8005f0,(%esp)
  800a79:	e8 8f fb ff ff       	call   80060d <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800a7e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800a81:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800a84:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800a87:	c9                   	leave  
  800a88:	c3                   	ret    

00800a89 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800a89:	55                   	push   %ebp
  800a8a:	89 e5                	mov    %esp,%ebp
  800a8c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  800a8f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800a92:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800a96:	8b 45 10             	mov    0x10(%ebp),%eax
  800a99:	89 44 24 08          	mov    %eax,0x8(%esp)
  800a9d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800aa0:	89 44 24 04          	mov    %eax,0x4(%esp)
  800aa4:	8b 45 08             	mov    0x8(%ebp),%eax
  800aa7:	89 04 24             	mov    %eax,(%esp)
  800aaa:	e8 82 ff ff ff       	call   800a31 <vsnprintf>
	va_end(ap);

	return rc;
}
  800aaf:	c9                   	leave  
  800ab0:	c3                   	ret    

00800ab1 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800ab1:	55                   	push   %ebp
  800ab2:	89 e5                	mov    %esp,%ebp
  800ab4:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800ab7:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  800aba:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800abe:	8b 45 10             	mov    0x10(%ebp),%eax
  800ac1:	89 44 24 08          	mov    %eax,0x8(%esp)
  800ac5:	8b 45 0c             	mov    0xc(%ebp),%eax
  800ac8:	89 44 24 04          	mov    %eax,0x4(%esp)
  800acc:	8b 45 08             	mov    0x8(%ebp),%eax
  800acf:	89 04 24             	mov    %eax,(%esp)
  800ad2:	e8 36 fb ff ff       	call   80060d <vprintfmt>
	va_end(ap);
}
  800ad7:	c9                   	leave  
  800ad8:	c3                   	ret    
  800ad9:	00 00                	add    %al,(%eax)
  800adb:	00 00                	add    %al,(%eax)
  800add:	00 00                	add    %al,(%eax)
	...

00800ae0 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800ae0:	55                   	push   %ebp
  800ae1:	89 e5                	mov    %esp,%ebp
  800ae3:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800ae6:	b8 00 00 00 00       	mov    $0x0,%eax
  800aeb:	80 3a 00             	cmpb   $0x0,(%edx)
  800aee:	74 09                	je     800af9 <strlen+0x19>
		n++;
  800af0:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800af3:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800af7:	75 f7                	jne    800af0 <strlen+0x10>
		n++;
	return n;
}
  800af9:	5d                   	pop    %ebp
  800afa:	c3                   	ret    

00800afb <strnlen>:

int
strnlen(const char *s, size_t size)
{
  800afb:	55                   	push   %ebp
  800afc:	89 e5                	mov    %esp,%ebp
  800afe:	53                   	push   %ebx
  800aff:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800b02:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800b05:	85 c9                	test   %ecx,%ecx
  800b07:	74 19                	je     800b22 <strnlen+0x27>
  800b09:	80 3b 00             	cmpb   $0x0,(%ebx)
  800b0c:	74 14                	je     800b22 <strnlen+0x27>
  800b0e:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800b13:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800b16:	39 c8                	cmp    %ecx,%eax
  800b18:	74 0d                	je     800b27 <strnlen+0x2c>
  800b1a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  800b1e:	75 f3                	jne    800b13 <strnlen+0x18>
  800b20:	eb 05                	jmp    800b27 <strnlen+0x2c>
  800b22:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800b27:	5b                   	pop    %ebx
  800b28:	5d                   	pop    %ebp
  800b29:	c3                   	ret    

00800b2a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800b2a:	55                   	push   %ebp
  800b2b:	89 e5                	mov    %esp,%ebp
  800b2d:	53                   	push   %ebx
  800b2e:	8b 45 08             	mov    0x8(%ebp),%eax
  800b31:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800b34:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800b39:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  800b3d:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800b40:	83 c2 01             	add    $0x1,%edx
  800b43:	84 c9                	test   %cl,%cl
  800b45:	75 f2                	jne    800b39 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800b47:	5b                   	pop    %ebx
  800b48:	5d                   	pop    %ebp
  800b49:	c3                   	ret    

00800b4a <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800b4a:	55                   	push   %ebp
  800b4b:	89 e5                	mov    %esp,%ebp
  800b4d:	56                   	push   %esi
  800b4e:	53                   	push   %ebx
  800b4f:	8b 45 08             	mov    0x8(%ebp),%eax
  800b52:	8b 55 0c             	mov    0xc(%ebp),%edx
  800b55:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800b58:	85 f6                	test   %esi,%esi
  800b5a:	74 18                	je     800b74 <strncpy+0x2a>
  800b5c:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800b61:	0f b6 1a             	movzbl (%edx),%ebx
  800b64:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800b67:	80 3a 01             	cmpb   $0x1,(%edx)
  800b6a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800b6d:	83 c1 01             	add    $0x1,%ecx
  800b70:	39 ce                	cmp    %ecx,%esi
  800b72:	77 ed                	ja     800b61 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800b74:	5b                   	pop    %ebx
  800b75:	5e                   	pop    %esi
  800b76:	5d                   	pop    %ebp
  800b77:	c3                   	ret    

00800b78 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800b78:	55                   	push   %ebp
  800b79:	89 e5                	mov    %esp,%ebp
  800b7b:	56                   	push   %esi
  800b7c:	53                   	push   %ebx
  800b7d:	8b 75 08             	mov    0x8(%ebp),%esi
  800b80:	8b 55 0c             	mov    0xc(%ebp),%edx
  800b83:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800b86:	89 f0                	mov    %esi,%eax
  800b88:	85 c9                	test   %ecx,%ecx
  800b8a:	74 27                	je     800bb3 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800b8c:	83 e9 01             	sub    $0x1,%ecx
  800b8f:	74 1d                	je     800bae <strlcpy+0x36>
  800b91:	0f b6 1a             	movzbl (%edx),%ebx
  800b94:	84 db                	test   %bl,%bl
  800b96:	74 16                	je     800bae <strlcpy+0x36>
			*dst++ = *src++;
  800b98:	88 18                	mov    %bl,(%eax)
  800b9a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800b9d:	83 e9 01             	sub    $0x1,%ecx
  800ba0:	74 0e                	je     800bb0 <strlcpy+0x38>
			*dst++ = *src++;
  800ba2:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800ba5:	0f b6 1a             	movzbl (%edx),%ebx
  800ba8:	84 db                	test   %bl,%bl
  800baa:	75 ec                	jne    800b98 <strlcpy+0x20>
  800bac:	eb 02                	jmp    800bb0 <strlcpy+0x38>
  800bae:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800bb0:	c6 00 00             	movb   $0x0,(%eax)
  800bb3:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800bb5:	5b                   	pop    %ebx
  800bb6:	5e                   	pop    %esi
  800bb7:	5d                   	pop    %ebp
  800bb8:	c3                   	ret    

00800bb9 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800bb9:	55                   	push   %ebp
  800bba:	89 e5                	mov    %esp,%ebp
  800bbc:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800bbf:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800bc2:	0f b6 01             	movzbl (%ecx),%eax
  800bc5:	84 c0                	test   %al,%al
  800bc7:	74 15                	je     800bde <strcmp+0x25>
  800bc9:	3a 02                	cmp    (%edx),%al
  800bcb:	75 11                	jne    800bde <strcmp+0x25>
		p++, q++;
  800bcd:	83 c1 01             	add    $0x1,%ecx
  800bd0:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800bd3:	0f b6 01             	movzbl (%ecx),%eax
  800bd6:	84 c0                	test   %al,%al
  800bd8:	74 04                	je     800bde <strcmp+0x25>
  800bda:	3a 02                	cmp    (%edx),%al
  800bdc:	74 ef                	je     800bcd <strcmp+0x14>
  800bde:	0f b6 c0             	movzbl %al,%eax
  800be1:	0f b6 12             	movzbl (%edx),%edx
  800be4:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800be6:	5d                   	pop    %ebp
  800be7:	c3                   	ret    

00800be8 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800be8:	55                   	push   %ebp
  800be9:	89 e5                	mov    %esp,%ebp
  800beb:	53                   	push   %ebx
  800bec:	8b 55 08             	mov    0x8(%ebp),%edx
  800bef:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800bf2:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800bf5:	85 c0                	test   %eax,%eax
  800bf7:	74 23                	je     800c1c <strncmp+0x34>
  800bf9:	0f b6 1a             	movzbl (%edx),%ebx
  800bfc:	84 db                	test   %bl,%bl
  800bfe:	74 24                	je     800c24 <strncmp+0x3c>
  800c00:	3a 19                	cmp    (%ecx),%bl
  800c02:	75 20                	jne    800c24 <strncmp+0x3c>
  800c04:	83 e8 01             	sub    $0x1,%eax
  800c07:	74 13                	je     800c1c <strncmp+0x34>
		n--, p++, q++;
  800c09:	83 c2 01             	add    $0x1,%edx
  800c0c:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800c0f:	0f b6 1a             	movzbl (%edx),%ebx
  800c12:	84 db                	test   %bl,%bl
  800c14:	74 0e                	je     800c24 <strncmp+0x3c>
  800c16:	3a 19                	cmp    (%ecx),%bl
  800c18:	74 ea                	je     800c04 <strncmp+0x1c>
  800c1a:	eb 08                	jmp    800c24 <strncmp+0x3c>
  800c1c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800c21:	5b                   	pop    %ebx
  800c22:	5d                   	pop    %ebp
  800c23:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800c24:	0f b6 02             	movzbl (%edx),%eax
  800c27:	0f b6 11             	movzbl (%ecx),%edx
  800c2a:	29 d0                	sub    %edx,%eax
  800c2c:	eb f3                	jmp    800c21 <strncmp+0x39>

00800c2e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800c2e:	55                   	push   %ebp
  800c2f:	89 e5                	mov    %esp,%ebp
  800c31:	8b 45 08             	mov    0x8(%ebp),%eax
  800c34:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800c38:	0f b6 10             	movzbl (%eax),%edx
  800c3b:	84 d2                	test   %dl,%dl
  800c3d:	74 15                	je     800c54 <strchr+0x26>
		if (*s == c)
  800c3f:	38 ca                	cmp    %cl,%dl
  800c41:	75 07                	jne    800c4a <strchr+0x1c>
  800c43:	eb 14                	jmp    800c59 <strchr+0x2b>
  800c45:	38 ca                	cmp    %cl,%dl
  800c47:	90                   	nop
  800c48:	74 0f                	je     800c59 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800c4a:	83 c0 01             	add    $0x1,%eax
  800c4d:	0f b6 10             	movzbl (%eax),%edx
  800c50:	84 d2                	test   %dl,%dl
  800c52:	75 f1                	jne    800c45 <strchr+0x17>
  800c54:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800c59:	5d                   	pop    %ebp
  800c5a:	c3                   	ret    

00800c5b <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800c5b:	55                   	push   %ebp
  800c5c:	89 e5                	mov    %esp,%ebp
  800c5e:	8b 45 08             	mov    0x8(%ebp),%eax
  800c61:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800c65:	0f b6 10             	movzbl (%eax),%edx
  800c68:	84 d2                	test   %dl,%dl
  800c6a:	74 18                	je     800c84 <strfind+0x29>
		if (*s == c)
  800c6c:	38 ca                	cmp    %cl,%dl
  800c6e:	75 0a                	jne    800c7a <strfind+0x1f>
  800c70:	eb 12                	jmp    800c84 <strfind+0x29>
  800c72:	38 ca                	cmp    %cl,%dl
  800c74:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800c78:	74 0a                	je     800c84 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800c7a:	83 c0 01             	add    $0x1,%eax
  800c7d:	0f b6 10             	movzbl (%eax),%edx
  800c80:	84 d2                	test   %dl,%dl
  800c82:	75 ee                	jne    800c72 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800c84:	5d                   	pop    %ebp
  800c85:	c3                   	ret    

00800c86 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800c86:	55                   	push   %ebp
  800c87:	89 e5                	mov    %esp,%ebp
  800c89:	83 ec 0c             	sub    $0xc,%esp
  800c8c:	89 1c 24             	mov    %ebx,(%esp)
  800c8f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c93:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800c97:	8b 7d 08             	mov    0x8(%ebp),%edi
  800c9a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800c9d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800ca0:	85 c9                	test   %ecx,%ecx
  800ca2:	74 30                	je     800cd4 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800ca4:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800caa:	75 25                	jne    800cd1 <memset+0x4b>
  800cac:	f6 c1 03             	test   $0x3,%cl
  800caf:	75 20                	jne    800cd1 <memset+0x4b>
		c &= 0xFF;
  800cb1:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800cb4:	89 d3                	mov    %edx,%ebx
  800cb6:	c1 e3 08             	shl    $0x8,%ebx
  800cb9:	89 d6                	mov    %edx,%esi
  800cbb:	c1 e6 18             	shl    $0x18,%esi
  800cbe:	89 d0                	mov    %edx,%eax
  800cc0:	c1 e0 10             	shl    $0x10,%eax
  800cc3:	09 f0                	or     %esi,%eax
  800cc5:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800cc7:	09 d8                	or     %ebx,%eax
  800cc9:	c1 e9 02             	shr    $0x2,%ecx
  800ccc:	fc                   	cld    
  800ccd:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800ccf:	eb 03                	jmp    800cd4 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800cd1:	fc                   	cld    
  800cd2:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800cd4:	89 f8                	mov    %edi,%eax
  800cd6:	8b 1c 24             	mov    (%esp),%ebx
  800cd9:	8b 74 24 04          	mov    0x4(%esp),%esi
  800cdd:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800ce1:	89 ec                	mov    %ebp,%esp
  800ce3:	5d                   	pop    %ebp
  800ce4:	c3                   	ret    

00800ce5 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800ce5:	55                   	push   %ebp
  800ce6:	89 e5                	mov    %esp,%ebp
  800ce8:	83 ec 08             	sub    $0x8,%esp
  800ceb:	89 34 24             	mov    %esi,(%esp)
  800cee:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800cf2:	8b 45 08             	mov    0x8(%ebp),%eax
  800cf5:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800cf8:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800cfb:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800cfd:	39 c6                	cmp    %eax,%esi
  800cff:	73 35                	jae    800d36 <memmove+0x51>
  800d01:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800d04:	39 d0                	cmp    %edx,%eax
  800d06:	73 2e                	jae    800d36 <memmove+0x51>
		s += n;
		d += n;
  800d08:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800d0a:	f6 c2 03             	test   $0x3,%dl
  800d0d:	75 1b                	jne    800d2a <memmove+0x45>
  800d0f:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800d15:	75 13                	jne    800d2a <memmove+0x45>
  800d17:	f6 c1 03             	test   $0x3,%cl
  800d1a:	75 0e                	jne    800d2a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800d1c:	83 ef 04             	sub    $0x4,%edi
  800d1f:	8d 72 fc             	lea    -0x4(%edx),%esi
  800d22:	c1 e9 02             	shr    $0x2,%ecx
  800d25:	fd                   	std    
  800d26:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800d28:	eb 09                	jmp    800d33 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800d2a:	83 ef 01             	sub    $0x1,%edi
  800d2d:	8d 72 ff             	lea    -0x1(%edx),%esi
  800d30:	fd                   	std    
  800d31:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800d33:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800d34:	eb 20                	jmp    800d56 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800d36:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800d3c:	75 15                	jne    800d53 <memmove+0x6e>
  800d3e:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800d44:	75 0d                	jne    800d53 <memmove+0x6e>
  800d46:	f6 c1 03             	test   $0x3,%cl
  800d49:	75 08                	jne    800d53 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800d4b:	c1 e9 02             	shr    $0x2,%ecx
  800d4e:	fc                   	cld    
  800d4f:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800d51:	eb 03                	jmp    800d56 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800d53:	fc                   	cld    
  800d54:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800d56:	8b 34 24             	mov    (%esp),%esi
  800d59:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800d5d:	89 ec                	mov    %ebp,%esp
  800d5f:	5d                   	pop    %ebp
  800d60:	c3                   	ret    

00800d61 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800d61:	55                   	push   %ebp
  800d62:	89 e5                	mov    %esp,%ebp
  800d64:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800d67:	8b 45 10             	mov    0x10(%ebp),%eax
  800d6a:	89 44 24 08          	mov    %eax,0x8(%esp)
  800d6e:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d71:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d75:	8b 45 08             	mov    0x8(%ebp),%eax
  800d78:	89 04 24             	mov    %eax,(%esp)
  800d7b:	e8 65 ff ff ff       	call   800ce5 <memmove>
}
  800d80:	c9                   	leave  
  800d81:	c3                   	ret    

00800d82 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800d82:	55                   	push   %ebp
  800d83:	89 e5                	mov    %esp,%ebp
  800d85:	57                   	push   %edi
  800d86:	56                   	push   %esi
  800d87:	53                   	push   %ebx
  800d88:	8b 75 08             	mov    0x8(%ebp),%esi
  800d8b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800d8e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800d91:	85 c9                	test   %ecx,%ecx
  800d93:	74 36                	je     800dcb <memcmp+0x49>
		if (*s1 != *s2)
  800d95:	0f b6 06             	movzbl (%esi),%eax
  800d98:	0f b6 1f             	movzbl (%edi),%ebx
  800d9b:	38 d8                	cmp    %bl,%al
  800d9d:	74 20                	je     800dbf <memcmp+0x3d>
  800d9f:	eb 14                	jmp    800db5 <memcmp+0x33>
  800da1:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800da6:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800dab:	83 c2 01             	add    $0x1,%edx
  800dae:	83 e9 01             	sub    $0x1,%ecx
  800db1:	38 d8                	cmp    %bl,%al
  800db3:	74 12                	je     800dc7 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800db5:	0f b6 c0             	movzbl %al,%eax
  800db8:	0f b6 db             	movzbl %bl,%ebx
  800dbb:	29 d8                	sub    %ebx,%eax
  800dbd:	eb 11                	jmp    800dd0 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800dbf:	83 e9 01             	sub    $0x1,%ecx
  800dc2:	ba 00 00 00 00       	mov    $0x0,%edx
  800dc7:	85 c9                	test   %ecx,%ecx
  800dc9:	75 d6                	jne    800da1 <memcmp+0x1f>
  800dcb:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800dd0:	5b                   	pop    %ebx
  800dd1:	5e                   	pop    %esi
  800dd2:	5f                   	pop    %edi
  800dd3:	5d                   	pop    %ebp
  800dd4:	c3                   	ret    

00800dd5 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800dd5:	55                   	push   %ebp
  800dd6:	89 e5                	mov    %esp,%ebp
  800dd8:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800ddb:	89 c2                	mov    %eax,%edx
  800ddd:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800de0:	39 d0                	cmp    %edx,%eax
  800de2:	73 15                	jae    800df9 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800de4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800de8:	38 08                	cmp    %cl,(%eax)
  800dea:	75 06                	jne    800df2 <memfind+0x1d>
  800dec:	eb 0b                	jmp    800df9 <memfind+0x24>
  800dee:	38 08                	cmp    %cl,(%eax)
  800df0:	74 07                	je     800df9 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800df2:	83 c0 01             	add    $0x1,%eax
  800df5:	39 c2                	cmp    %eax,%edx
  800df7:	77 f5                	ja     800dee <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800df9:	5d                   	pop    %ebp
  800dfa:	c3                   	ret    

00800dfb <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800dfb:	55                   	push   %ebp
  800dfc:	89 e5                	mov    %esp,%ebp
  800dfe:	57                   	push   %edi
  800dff:	56                   	push   %esi
  800e00:	53                   	push   %ebx
  800e01:	83 ec 04             	sub    $0x4,%esp
  800e04:	8b 55 08             	mov    0x8(%ebp),%edx
  800e07:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800e0a:	0f b6 02             	movzbl (%edx),%eax
  800e0d:	3c 20                	cmp    $0x20,%al
  800e0f:	74 04                	je     800e15 <strtol+0x1a>
  800e11:	3c 09                	cmp    $0x9,%al
  800e13:	75 0e                	jne    800e23 <strtol+0x28>
		s++;
  800e15:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800e18:	0f b6 02             	movzbl (%edx),%eax
  800e1b:	3c 20                	cmp    $0x20,%al
  800e1d:	74 f6                	je     800e15 <strtol+0x1a>
  800e1f:	3c 09                	cmp    $0x9,%al
  800e21:	74 f2                	je     800e15 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800e23:	3c 2b                	cmp    $0x2b,%al
  800e25:	75 0c                	jne    800e33 <strtol+0x38>
		s++;
  800e27:	83 c2 01             	add    $0x1,%edx
  800e2a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800e31:	eb 15                	jmp    800e48 <strtol+0x4d>
	else if (*s == '-')
  800e33:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800e3a:	3c 2d                	cmp    $0x2d,%al
  800e3c:	75 0a                	jne    800e48 <strtol+0x4d>
		s++, neg = 1;
  800e3e:	83 c2 01             	add    $0x1,%edx
  800e41:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800e48:	85 db                	test   %ebx,%ebx
  800e4a:	0f 94 c0             	sete   %al
  800e4d:	74 05                	je     800e54 <strtol+0x59>
  800e4f:	83 fb 10             	cmp    $0x10,%ebx
  800e52:	75 18                	jne    800e6c <strtol+0x71>
  800e54:	80 3a 30             	cmpb   $0x30,(%edx)
  800e57:	75 13                	jne    800e6c <strtol+0x71>
  800e59:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800e5d:	8d 76 00             	lea    0x0(%esi),%esi
  800e60:	75 0a                	jne    800e6c <strtol+0x71>
		s += 2, base = 16;
  800e62:	83 c2 02             	add    $0x2,%edx
  800e65:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800e6a:	eb 15                	jmp    800e81 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800e6c:	84 c0                	test   %al,%al
  800e6e:	66 90                	xchg   %ax,%ax
  800e70:	74 0f                	je     800e81 <strtol+0x86>
  800e72:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800e77:	80 3a 30             	cmpb   $0x30,(%edx)
  800e7a:	75 05                	jne    800e81 <strtol+0x86>
		s++, base = 8;
  800e7c:	83 c2 01             	add    $0x1,%edx
  800e7f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800e81:	b8 00 00 00 00       	mov    $0x0,%eax
  800e86:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800e88:	0f b6 0a             	movzbl (%edx),%ecx
  800e8b:	89 cf                	mov    %ecx,%edi
  800e8d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800e90:	80 fb 09             	cmp    $0x9,%bl
  800e93:	77 08                	ja     800e9d <strtol+0xa2>
			dig = *s - '0';
  800e95:	0f be c9             	movsbl %cl,%ecx
  800e98:	83 e9 30             	sub    $0x30,%ecx
  800e9b:	eb 1e                	jmp    800ebb <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800e9d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800ea0:	80 fb 19             	cmp    $0x19,%bl
  800ea3:	77 08                	ja     800ead <strtol+0xb2>
			dig = *s - 'a' + 10;
  800ea5:	0f be c9             	movsbl %cl,%ecx
  800ea8:	83 e9 57             	sub    $0x57,%ecx
  800eab:	eb 0e                	jmp    800ebb <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800ead:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800eb0:	80 fb 19             	cmp    $0x19,%bl
  800eb3:	77 15                	ja     800eca <strtol+0xcf>
			dig = *s - 'A' + 10;
  800eb5:	0f be c9             	movsbl %cl,%ecx
  800eb8:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800ebb:	39 f1                	cmp    %esi,%ecx
  800ebd:	7d 0b                	jge    800eca <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800ebf:	83 c2 01             	add    $0x1,%edx
  800ec2:	0f af c6             	imul   %esi,%eax
  800ec5:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800ec8:	eb be                	jmp    800e88 <strtol+0x8d>
  800eca:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800ecc:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800ed0:	74 05                	je     800ed7 <strtol+0xdc>
		*endptr = (char *) s;
  800ed2:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800ed5:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800ed7:	89 ca                	mov    %ecx,%edx
  800ed9:	f7 da                	neg    %edx
  800edb:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800edf:	0f 45 c2             	cmovne %edx,%eax
}
  800ee2:	83 c4 04             	add    $0x4,%esp
  800ee5:	5b                   	pop    %ebx
  800ee6:	5e                   	pop    %esi
  800ee7:	5f                   	pop    %edi
  800ee8:	5d                   	pop    %ebp
  800ee9:	c3                   	ret    
	...

00800eec <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800eec:	55                   	push   %ebp
  800eed:	89 e5                	mov    %esp,%ebp
  800eef:	83 ec 0c             	sub    $0xc,%esp
  800ef2:	89 1c 24             	mov    %ebx,(%esp)
  800ef5:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ef9:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800efd:	ba 00 00 00 00       	mov    $0x0,%edx
  800f02:	b8 01 00 00 00       	mov    $0x1,%eax
  800f07:	89 d1                	mov    %edx,%ecx
  800f09:	89 d3                	mov    %edx,%ebx
  800f0b:	89 d7                	mov    %edx,%edi
  800f0d:	89 d6                	mov    %edx,%esi
  800f0f:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800f11:	8b 1c 24             	mov    (%esp),%ebx
  800f14:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f18:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f1c:	89 ec                	mov    %ebp,%esp
  800f1e:	5d                   	pop    %ebp
  800f1f:	c3                   	ret    

00800f20 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800f20:	55                   	push   %ebp
  800f21:	89 e5                	mov    %esp,%ebp
  800f23:	83 ec 0c             	sub    $0xc,%esp
  800f26:	89 1c 24             	mov    %ebx,(%esp)
  800f29:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f2d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f31:	b8 00 00 00 00       	mov    $0x0,%eax
  800f36:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f39:	8b 55 08             	mov    0x8(%ebp),%edx
  800f3c:	89 c3                	mov    %eax,%ebx
  800f3e:	89 c7                	mov    %eax,%edi
  800f40:	89 c6                	mov    %eax,%esi
  800f42:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800f44:	8b 1c 24             	mov    (%esp),%ebx
  800f47:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f4b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f4f:	89 ec                	mov    %ebp,%esp
  800f51:	5d                   	pop    %ebp
  800f52:	c3                   	ret    

00800f53 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800f53:	55                   	push   %ebp
  800f54:	89 e5                	mov    %esp,%ebp
  800f56:	83 ec 0c             	sub    $0xc,%esp
  800f59:	89 1c 24             	mov    %ebx,(%esp)
  800f5c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f60:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f64:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f69:	b8 10 00 00 00       	mov    $0x10,%eax
  800f6e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f71:	8b 55 08             	mov    0x8(%ebp),%edx
  800f74:	89 df                	mov    %ebx,%edi
  800f76:	89 de                	mov    %ebx,%esi
  800f78:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800f7a:	8b 1c 24             	mov    (%esp),%ebx
  800f7d:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f81:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f85:	89 ec                	mov    %ebp,%esp
  800f87:	5d                   	pop    %ebp
  800f88:	c3                   	ret    

00800f89 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800f89:	55                   	push   %ebp
  800f8a:	89 e5                	mov    %esp,%ebp
  800f8c:	83 ec 0c             	sub    $0xc,%esp
  800f8f:	89 1c 24             	mov    %ebx,(%esp)
  800f92:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f96:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f9a:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f9f:	b8 0f 00 00 00       	mov    $0xf,%eax
  800fa4:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fa7:	8b 55 08             	mov    0x8(%ebp),%edx
  800faa:	89 df                	mov    %ebx,%edi
  800fac:	89 de                	mov    %ebx,%esi
  800fae:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800fb0:	8b 1c 24             	mov    (%esp),%ebx
  800fb3:	8b 74 24 04          	mov    0x4(%esp),%esi
  800fb7:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800fbb:	89 ec                	mov    %ebp,%esp
  800fbd:	5d                   	pop    %ebp
  800fbe:	c3                   	ret    

00800fbf <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800fbf:	55                   	push   %ebp
  800fc0:	89 e5                	mov    %esp,%ebp
  800fc2:	83 ec 0c             	sub    $0xc,%esp
  800fc5:	89 1c 24             	mov    %ebx,(%esp)
  800fc8:	89 74 24 04          	mov    %esi,0x4(%esp)
  800fcc:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fd0:	ba 00 00 00 00       	mov    $0x0,%edx
  800fd5:	b8 0e 00 00 00       	mov    $0xe,%eax
  800fda:	89 d1                	mov    %edx,%ecx
  800fdc:	89 d3                	mov    %edx,%ebx
  800fde:	89 d7                	mov    %edx,%edi
  800fe0:	89 d6                	mov    %edx,%esi
  800fe2:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800fe4:	8b 1c 24             	mov    (%esp),%ebx
  800fe7:	8b 74 24 04          	mov    0x4(%esp),%esi
  800feb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800fef:	89 ec                	mov    %ebp,%esp
  800ff1:	5d                   	pop    %ebp
  800ff2:	c3                   	ret    

00800ff3 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800ff3:	55                   	push   %ebp
  800ff4:	89 e5                	mov    %esp,%ebp
  800ff6:	83 ec 38             	sub    $0x38,%esp
  800ff9:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800ffc:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fff:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801002:	b9 00 00 00 00       	mov    $0x0,%ecx
  801007:	b8 0d 00 00 00       	mov    $0xd,%eax
  80100c:	8b 55 08             	mov    0x8(%ebp),%edx
  80100f:	89 cb                	mov    %ecx,%ebx
  801011:	89 cf                	mov    %ecx,%edi
  801013:	89 ce                	mov    %ecx,%esi
  801015:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801017:	85 c0                	test   %eax,%eax
  801019:	7e 28                	jle    801043 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  80101b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80101f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  801026:	00 
  801027:	c7 44 24 08 ab 33 80 	movl   $0x8033ab,0x8(%esp)
  80102e:	00 
  80102f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801036:	00 
  801037:	c7 04 24 c8 33 80 00 	movl   $0x8033c8,(%esp)
  80103e:	e8 59 f3 ff ff       	call   80039c <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  801043:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801046:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801049:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80104c:	89 ec                	mov    %ebp,%esp
  80104e:	5d                   	pop    %ebp
  80104f:	c3                   	ret    

00801050 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  801050:	55                   	push   %ebp
  801051:	89 e5                	mov    %esp,%ebp
  801053:	83 ec 38             	sub    $0x38,%esp
  801056:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801059:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80105c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80105f:	be 00 00 00 00       	mov    $0x0,%esi
  801064:	b8 0c 00 00 00       	mov    $0xc,%eax
  801069:	8b 7d 14             	mov    0x14(%ebp),%edi
  80106c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80106f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801072:	8b 55 08             	mov    0x8(%ebp),%edx
  801075:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801077:	85 c0                	test   %eax,%eax
  801079:	7e 28                	jle    8010a3 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  80107b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80107f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  801086:	00 
  801087:	c7 44 24 08 ab 33 80 	movl   $0x8033ab,0x8(%esp)
  80108e:	00 
  80108f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801096:	00 
  801097:	c7 04 24 c8 33 80 00 	movl   $0x8033c8,(%esp)
  80109e:	e8 f9 f2 ff ff       	call   80039c <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  8010a3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010a6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010a9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010ac:	89 ec                	mov    %ebp,%esp
  8010ae:	5d                   	pop    %ebp
  8010af:	c3                   	ret    

008010b0 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  8010b0:	55                   	push   %ebp
  8010b1:	89 e5                	mov    %esp,%ebp
  8010b3:	83 ec 38             	sub    $0x38,%esp
  8010b6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010b9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010bc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010bf:	bb 00 00 00 00       	mov    $0x0,%ebx
  8010c4:	b8 0a 00 00 00       	mov    $0xa,%eax
  8010c9:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010cc:	8b 55 08             	mov    0x8(%ebp),%edx
  8010cf:	89 df                	mov    %ebx,%edi
  8010d1:	89 de                	mov    %ebx,%esi
  8010d3:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010d5:	85 c0                	test   %eax,%eax
  8010d7:	7e 28                	jle    801101 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010d9:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010dd:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  8010e4:	00 
  8010e5:	c7 44 24 08 ab 33 80 	movl   $0x8033ab,0x8(%esp)
  8010ec:	00 
  8010ed:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010f4:	00 
  8010f5:	c7 04 24 c8 33 80 00 	movl   $0x8033c8,(%esp)
  8010fc:	e8 9b f2 ff ff       	call   80039c <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  801101:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801104:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801107:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80110a:	89 ec                	mov    %ebp,%esp
  80110c:	5d                   	pop    %ebp
  80110d:	c3                   	ret    

0080110e <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  80110e:	55                   	push   %ebp
  80110f:	89 e5                	mov    %esp,%ebp
  801111:	83 ec 38             	sub    $0x38,%esp
  801114:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801117:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80111a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80111d:	bb 00 00 00 00       	mov    $0x0,%ebx
  801122:	b8 09 00 00 00       	mov    $0x9,%eax
  801127:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80112a:	8b 55 08             	mov    0x8(%ebp),%edx
  80112d:	89 df                	mov    %ebx,%edi
  80112f:	89 de                	mov    %ebx,%esi
  801131:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801133:	85 c0                	test   %eax,%eax
  801135:	7e 28                	jle    80115f <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801137:	89 44 24 10          	mov    %eax,0x10(%esp)
  80113b:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  801142:	00 
  801143:	c7 44 24 08 ab 33 80 	movl   $0x8033ab,0x8(%esp)
  80114a:	00 
  80114b:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801152:	00 
  801153:	c7 04 24 c8 33 80 00 	movl   $0x8033c8,(%esp)
  80115a:	e8 3d f2 ff ff       	call   80039c <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  80115f:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801162:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801165:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801168:	89 ec                	mov    %ebp,%esp
  80116a:	5d                   	pop    %ebp
  80116b:	c3                   	ret    

0080116c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  80116c:	55                   	push   %ebp
  80116d:	89 e5                	mov    %esp,%ebp
  80116f:	83 ec 38             	sub    $0x38,%esp
  801172:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801175:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801178:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80117b:	bb 00 00 00 00       	mov    $0x0,%ebx
  801180:	b8 08 00 00 00       	mov    $0x8,%eax
  801185:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801188:	8b 55 08             	mov    0x8(%ebp),%edx
  80118b:	89 df                	mov    %ebx,%edi
  80118d:	89 de                	mov    %ebx,%esi
  80118f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801191:	85 c0                	test   %eax,%eax
  801193:	7e 28                	jle    8011bd <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801195:	89 44 24 10          	mov    %eax,0x10(%esp)
  801199:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  8011a0:	00 
  8011a1:	c7 44 24 08 ab 33 80 	movl   $0x8033ab,0x8(%esp)
  8011a8:	00 
  8011a9:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8011b0:	00 
  8011b1:	c7 04 24 c8 33 80 00 	movl   $0x8033c8,(%esp)
  8011b8:	e8 df f1 ff ff       	call   80039c <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  8011bd:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8011c0:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8011c3:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8011c6:	89 ec                	mov    %ebp,%esp
  8011c8:	5d                   	pop    %ebp
  8011c9:	c3                   	ret    

008011ca <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  8011ca:	55                   	push   %ebp
  8011cb:	89 e5                	mov    %esp,%ebp
  8011cd:	83 ec 38             	sub    $0x38,%esp
  8011d0:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8011d3:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8011d6:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011d9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8011de:	b8 06 00 00 00       	mov    $0x6,%eax
  8011e3:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8011e6:	8b 55 08             	mov    0x8(%ebp),%edx
  8011e9:	89 df                	mov    %ebx,%edi
  8011eb:	89 de                	mov    %ebx,%esi
  8011ed:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8011ef:	85 c0                	test   %eax,%eax
  8011f1:	7e 28                	jle    80121b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8011f3:	89 44 24 10          	mov    %eax,0x10(%esp)
  8011f7:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  8011fe:	00 
  8011ff:	c7 44 24 08 ab 33 80 	movl   $0x8033ab,0x8(%esp)
  801206:	00 
  801207:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80120e:	00 
  80120f:	c7 04 24 c8 33 80 00 	movl   $0x8033c8,(%esp)
  801216:	e8 81 f1 ff ff       	call   80039c <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  80121b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80121e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801221:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801224:	89 ec                	mov    %ebp,%esp
  801226:	5d                   	pop    %ebp
  801227:	c3                   	ret    

00801228 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  801228:	55                   	push   %ebp
  801229:	89 e5                	mov    %esp,%ebp
  80122b:	83 ec 38             	sub    $0x38,%esp
  80122e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801231:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801234:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801237:	b8 05 00 00 00       	mov    $0x5,%eax
  80123c:	8b 75 18             	mov    0x18(%ebp),%esi
  80123f:	8b 7d 14             	mov    0x14(%ebp),%edi
  801242:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801245:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801248:	8b 55 08             	mov    0x8(%ebp),%edx
  80124b:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80124d:	85 c0                	test   %eax,%eax
  80124f:	7e 28                	jle    801279 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801251:	89 44 24 10          	mov    %eax,0x10(%esp)
  801255:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  80125c:	00 
  80125d:	c7 44 24 08 ab 33 80 	movl   $0x8033ab,0x8(%esp)
  801264:	00 
  801265:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80126c:	00 
  80126d:	c7 04 24 c8 33 80 00 	movl   $0x8033c8,(%esp)
  801274:	e8 23 f1 ff ff       	call   80039c <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801279:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80127c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80127f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801282:	89 ec                	mov    %ebp,%esp
  801284:	5d                   	pop    %ebp
  801285:	c3                   	ret    

00801286 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801286:	55                   	push   %ebp
  801287:	89 e5                	mov    %esp,%ebp
  801289:	83 ec 38             	sub    $0x38,%esp
  80128c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80128f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801292:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801295:	be 00 00 00 00       	mov    $0x0,%esi
  80129a:	b8 04 00 00 00       	mov    $0x4,%eax
  80129f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8012a2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8012a5:	8b 55 08             	mov    0x8(%ebp),%edx
  8012a8:	89 f7                	mov    %esi,%edi
  8012aa:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8012ac:	85 c0                	test   %eax,%eax
  8012ae:	7e 28                	jle    8012d8 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  8012b0:	89 44 24 10          	mov    %eax,0x10(%esp)
  8012b4:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  8012bb:	00 
  8012bc:	c7 44 24 08 ab 33 80 	movl   $0x8033ab,0x8(%esp)
  8012c3:	00 
  8012c4:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8012cb:	00 
  8012cc:	c7 04 24 c8 33 80 00 	movl   $0x8033c8,(%esp)
  8012d3:	e8 c4 f0 ff ff       	call   80039c <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  8012d8:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8012db:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8012de:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8012e1:	89 ec                	mov    %ebp,%esp
  8012e3:	5d                   	pop    %ebp
  8012e4:	c3                   	ret    

008012e5 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  8012e5:	55                   	push   %ebp
  8012e6:	89 e5                	mov    %esp,%ebp
  8012e8:	83 ec 0c             	sub    $0xc,%esp
  8012eb:	89 1c 24             	mov    %ebx,(%esp)
  8012ee:	89 74 24 04          	mov    %esi,0x4(%esp)
  8012f2:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8012f6:	ba 00 00 00 00       	mov    $0x0,%edx
  8012fb:	b8 0b 00 00 00       	mov    $0xb,%eax
  801300:	89 d1                	mov    %edx,%ecx
  801302:	89 d3                	mov    %edx,%ebx
  801304:	89 d7                	mov    %edx,%edi
  801306:	89 d6                	mov    %edx,%esi
  801308:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  80130a:	8b 1c 24             	mov    (%esp),%ebx
  80130d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801311:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801315:	89 ec                	mov    %ebp,%esp
  801317:	5d                   	pop    %ebp
  801318:	c3                   	ret    

00801319 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801319:	55                   	push   %ebp
  80131a:	89 e5                	mov    %esp,%ebp
  80131c:	83 ec 0c             	sub    $0xc,%esp
  80131f:	89 1c 24             	mov    %ebx,(%esp)
  801322:	89 74 24 04          	mov    %esi,0x4(%esp)
  801326:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80132a:	ba 00 00 00 00       	mov    $0x0,%edx
  80132f:	b8 02 00 00 00       	mov    $0x2,%eax
  801334:	89 d1                	mov    %edx,%ecx
  801336:	89 d3                	mov    %edx,%ebx
  801338:	89 d7                	mov    %edx,%edi
  80133a:	89 d6                	mov    %edx,%esi
  80133c:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  80133e:	8b 1c 24             	mov    (%esp),%ebx
  801341:	8b 74 24 04          	mov    0x4(%esp),%esi
  801345:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801349:	89 ec                	mov    %ebp,%esp
  80134b:	5d                   	pop    %ebp
  80134c:	c3                   	ret    

0080134d <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  80134d:	55                   	push   %ebp
  80134e:	89 e5                	mov    %esp,%ebp
  801350:	83 ec 38             	sub    $0x38,%esp
  801353:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801356:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801359:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80135c:	b9 00 00 00 00       	mov    $0x0,%ecx
  801361:	b8 03 00 00 00       	mov    $0x3,%eax
  801366:	8b 55 08             	mov    0x8(%ebp),%edx
  801369:	89 cb                	mov    %ecx,%ebx
  80136b:	89 cf                	mov    %ecx,%edi
  80136d:	89 ce                	mov    %ecx,%esi
  80136f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801371:	85 c0                	test   %eax,%eax
  801373:	7e 28                	jle    80139d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  801375:	89 44 24 10          	mov    %eax,0x10(%esp)
  801379:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801380:	00 
  801381:	c7 44 24 08 ab 33 80 	movl   $0x8033ab,0x8(%esp)
  801388:	00 
  801389:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801390:	00 
  801391:	c7 04 24 c8 33 80 00 	movl   $0x8033c8,(%esp)
  801398:	e8 ff ef ff ff       	call   80039c <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80139d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8013a0:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8013a3:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8013a6:	89 ec                	mov    %ebp,%esp
  8013a8:	5d                   	pop    %ebp
  8013a9:	c3                   	ret    
  8013aa:	00 00                	add    %al,(%eax)
  8013ac:	00 00                	add    %al,(%eax)
	...

008013b0 <sfork>:
}

// Challenge!
int
sfork(void)
{
  8013b0:	55                   	push   %ebp
  8013b1:	89 e5                	mov    %esp,%ebp
  8013b3:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  8013b6:	c7 44 24 08 d6 33 80 	movl   $0x8033d6,0x8(%esp)
  8013bd:	00 
  8013be:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  8013c5:	00 
  8013c6:	c7 04 24 ec 33 80 00 	movl   $0x8033ec,(%esp)
  8013cd:	e8 ca ef ff ff       	call   80039c <_panic>

008013d2 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  8013d2:	55                   	push   %ebp
  8013d3:	89 e5                	mov    %esp,%ebp
  8013d5:	57                   	push   %edi
  8013d6:	56                   	push   %esi
  8013d7:	53                   	push   %ebx
  8013d8:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  8013db:	c7 04 24 3c 16 80 00 	movl   $0x80163c,(%esp)
  8013e2:	e8 2d 18 00 00       	call   802c14 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  8013e7:	ba 07 00 00 00       	mov    $0x7,%edx
  8013ec:	89 d0                	mov    %edx,%eax
  8013ee:	cd 30                	int    $0x30
  8013f0:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  8013f3:	85 c0                	test   %eax,%eax
  8013f5:	79 20                	jns    801417 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  8013f7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8013fb:	c7 44 24 08 5c 34 80 	movl   $0x80345c,0x8(%esp)
  801402:	00 
  801403:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  80140a:	00 
  80140b:	c7 04 24 ec 33 80 00 	movl   $0x8033ec,(%esp)
  801412:	e8 85 ef ff ff       	call   80039c <_panic>
    } else if (childId>0) {
  801417:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  80141b:	0f 8e f3 01 00 00    	jle    801614 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  801421:	c7 44 24 04 84 2c 80 	movl   $0x802c84,0x4(%esp)
  801428:	00 
  801429:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80142c:	89 04 24             	mov    %eax,(%esp)
  80142f:	e8 7c fc ff ff       	call   8010b0 <sys_env_set_pgfault_upcall>
  801434:	85 c0                	test   %eax,%eax
  801436:	74 20                	je     801458 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  801438:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80143c:	c7 44 24 08 80 34 80 	movl   $0x803480,0x8(%esp)
  801443:	00 
  801444:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  80144b:	00 
  80144c:	c7 04 24 ec 33 80 00 	movl   $0x8033ec,(%esp)
  801453:	e8 44 ef ff ff       	call   80039c <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  801458:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  80145f:	00 
  801460:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  801467:	ee 
  801468:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80146b:	89 04 24             	mov    %eax,(%esp)
  80146e:	e8 13 fe ff ff       	call   801286 <sys_page_alloc>
  801473:	85 c0                	test   %eax,%eax
  801475:	79 20                	jns    801497 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  801477:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80147b:	c7 44 24 08 b0 34 80 	movl   $0x8034b0,0x8(%esp)
  801482:	00 
  801483:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  80148a:	00 
  80148b:	c7 04 24 ec 33 80 00 	movl   $0x8033ec,(%esp)
  801492:	e8 05 ef ff ff       	call   80039c <_panic>
  801497:	be 00 00 80 00       	mov    $0x800000,%esi
  80149c:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  8014a1:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  8014a6:	89 f0                	mov    %esi,%eax
  8014a8:	c1 e8 16             	shr    $0x16,%eax
  8014ab:	8b 04 87             	mov    (%edi,%eax,4),%eax
  8014ae:	a8 01                	test   $0x1,%al
  8014b0:	0f 84 13 01 00 00    	je     8015c9 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  8014b6:	89 f0                	mov    %esi,%eax
  8014b8:	c1 e8 0c             	shr    $0xc,%eax
  8014bb:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  8014c2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8014c5:	25 07 0e 00 00       	and    $0xe07,%eax
  8014ca:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  8014cd:	e8 47 fe ff ff       	call   801319 <sys_getenvid>
  8014d2:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  8014d5:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  8014d9:	0f 84 ea 00 00 00    	je     8015c9 <fork+0x1f7>
  8014df:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  8014e6:	0f 84 9d 00 00 00    	je     801589 <fork+0x1b7>
  8014ec:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  8014f3:	0f 85 90 00 00 00    	jne    801589 <fork+0x1b7>
    perm    &= (~PTE_W);
  8014f9:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8014fc:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  8014ff:	80 cc 08             	or     $0x8,%ah
  801502:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801505:	89 75 e0             	mov    %esi,-0x20(%ebp)
  801508:	89 44 24 10          	mov    %eax,0x10(%esp)
  80150c:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801510:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801513:	89 44 24 08          	mov    %eax,0x8(%esp)
  801517:	89 74 24 04          	mov    %esi,0x4(%esp)
  80151b:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80151e:	89 04 24             	mov    %eax,(%esp)
  801521:	e8 02 fd ff ff       	call   801228 <sys_page_map>
  801526:	85 c0                	test   %eax,%eax
  801528:	79 1b                	jns    801545 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80152a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80152e:	89 74 24 08          	mov    %esi,0x8(%esp)
  801532:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801535:	89 44 24 04          	mov    %eax,0x4(%esp)
  801539:	c7 04 24 d8 34 80 00 	movl   $0x8034d8,(%esp)
  801540:	e8 1c ef ff ff       	call   800461 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  801545:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801548:	89 44 24 10          	mov    %eax,0x10(%esp)
  80154c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80154f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801553:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801556:	89 44 24 08          	mov    %eax,0x8(%esp)
  80155a:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80155d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801561:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801564:	89 04 24             	mov    %eax,(%esp)
  801567:	e8 bc fc ff ff       	call   801228 <sys_page_map>
  80156c:	85 c0                	test   %eax,%eax
  80156e:	79 59                	jns    8015c9 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  801570:	89 44 24 08          	mov    %eax,0x8(%esp)
  801574:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801577:	89 44 24 04          	mov    %eax,0x4(%esp)
  80157b:	c7 04 24 18 35 80 00 	movl   $0x803518,(%esp)
  801582:	e8 da ee ff ff       	call   800461 <cprintf>
  801587:	eb 40                	jmp    8015c9 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801589:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80158c:	89 44 24 10          	mov    %eax,0x10(%esp)
  801590:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801594:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801597:	89 44 24 08          	mov    %eax,0x8(%esp)
  80159b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80159f:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8015a2:	89 04 24             	mov    %eax,(%esp)
  8015a5:	e8 7e fc ff ff       	call   801228 <sys_page_map>
  8015aa:	85 c0                	test   %eax,%eax
  8015ac:	79 1b                	jns    8015c9 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  8015ae:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8015b2:	89 74 24 08          	mov    %esi,0x8(%esp)
  8015b6:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8015b9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8015bd:	c7 04 24 d8 34 80 00 	movl   $0x8034d8,(%esp)
  8015c4:	e8 98 ee ff ff       	call   800461 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  8015c9:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  8015cf:	89 de                	mov    %ebx,%esi
  8015d1:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  8015d7:	0f 85 c9 fe ff ff    	jne    8014a6 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  8015dd:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8015e4:	00 
  8015e5:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8015e8:	89 04 24             	mov    %eax,(%esp)
  8015eb:	e8 7c fb ff ff       	call   80116c <sys_env_set_status>
  8015f0:	85 c0                	test   %eax,%eax
  8015f2:	79 3d                	jns    801631 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  8015f4:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8015f8:	c7 44 24 08 4c 35 80 	movl   $0x80354c,0x8(%esp)
  8015ff:	00 
  801600:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  801607:	00 
  801608:	c7 04 24 ec 33 80 00 	movl   $0x8033ec,(%esp)
  80160f:	e8 88 ed ff ff       	call   80039c <_panic>
    } else if (childId==0) {
  801614:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  801618:	75 17                	jne    801631 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  80161a:	e8 fa fc ff ff       	call   801319 <sys_getenvid>
  80161f:	25 ff 03 00 00       	and    $0x3ff,%eax
  801624:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801627:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  80162c:	a3 78 70 80 00       	mov    %eax,0x807078
    }
    return childId;
}
  801631:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801634:	83 c4 3c             	add    $0x3c,%esp
  801637:	5b                   	pop    %ebx
  801638:	5e                   	pop    %esi
  801639:	5f                   	pop    %edi
  80163a:	5d                   	pop    %ebp
  80163b:	c3                   	ret    

0080163c <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  80163c:	55                   	push   %ebp
  80163d:	89 e5                	mov    %esp,%ebp
  80163f:	57                   	push   %edi
  801640:	56                   	push   %esi
  801641:	53                   	push   %ebx
  801642:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  801645:	8b 45 08             	mov    0x8(%ebp),%eax
  801648:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  80164a:	8b 50 04             	mov    0x4(%eax),%edx
  80164d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  801650:	89 fe                	mov    %edi,%esi
  801652:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  801658:	e8 bc fc ff ff       	call   801319 <sys_getenvid>
  80165d:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  80165f:	89 f2                	mov    %esi,%edx
  801661:	89 f0                	mov    %esi,%eax
  801663:	c1 e8 16             	shr    $0x16,%eax
  801666:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80166d:	a8 01                	test   $0x1,%al
  80166f:	74 3e                	je     8016af <pgfault+0x73>
  801671:	c1 ea 0c             	shr    $0xc,%edx
  801674:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  80167b:	a8 01                	test   $0x1,%al
  80167d:	74 30                	je     8016af <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  80167f:	c1 ef 0c             	shr    $0xc,%edi
  801682:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  801689:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  80168f:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801692:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801696:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80169d:	00 
  80169e:	89 1c 24             	mov    %ebx,(%esp)
  8016a1:	e8 e0 fb ff ff       	call   801286 <sys_page_alloc>
  8016a6:	85 c0                	test   %eax,%eax
  8016a8:	74 46                	je     8016f0 <pgfault+0xb4>
  8016aa:	e9 cd 00 00 00       	jmp    80177c <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  8016af:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8016b2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8016b6:	8b 55 08             	mov    0x8(%ebp),%edx
  8016b9:	8b 42 28             	mov    0x28(%edx),%eax
  8016bc:	89 44 24 08          	mov    %eax,0x8(%esp)
  8016c0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8016c4:	c7 04 24 6c 35 80 00 	movl   $0x80356c,(%esp)
  8016cb:	e8 91 ed ff ff       	call   800461 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  8016d0:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8016d4:	c7 44 24 08 f7 33 80 	movl   $0x8033f7,0x8(%esp)
  8016db:	00 
  8016dc:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  8016e3:	00 
  8016e4:	c7 04 24 ec 33 80 00 	movl   $0x8033ec,(%esp)
  8016eb:	e8 ac ec ff ff       	call   80039c <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  8016f0:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  8016f7:	00 
  8016f8:	89 74 24 04          	mov    %esi,0x4(%esp)
  8016fc:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  801703:	e8 dd f5 ff ff       	call   800ce5 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  801708:	89 7c 24 10          	mov    %edi,0x10(%esp)
  80170c:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801710:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801714:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80171b:	00 
  80171c:	89 1c 24             	mov    %ebx,(%esp)
  80171f:	e8 04 fb ff ff       	call   801228 <sys_page_map>
  801724:	85 c0                	test   %eax,%eax
  801726:	74 20                	je     801748 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  801728:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80172c:	c7 44 24 08 09 34 80 	movl   $0x803409,0x8(%esp)
  801733:	00 
  801734:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  80173b:	00 
  80173c:	c7 04 24 ec 33 80 00 	movl   $0x8033ec,(%esp)
  801743:	e8 54 ec ff ff       	call   80039c <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  801748:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80174f:	00 
  801750:	89 1c 24             	mov    %ebx,(%esp)
  801753:	e8 72 fa ff ff       	call   8011ca <sys_page_unmap>
  801758:	85 c0                	test   %eax,%eax
  80175a:	74 40                	je     80179c <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  80175c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801760:	c7 44 24 08 24 34 80 	movl   $0x803424,0x8(%esp)
  801767:	00 
  801768:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  80176f:	00 
  801770:	c7 04 24 ec 33 80 00 	movl   $0x8033ec,(%esp)
  801777:	e8 20 ec ff ff       	call   80039c <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  80177c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801780:	c7 44 24 08 41 34 80 	movl   $0x803441,0x8(%esp)
  801787:	00 
  801788:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  80178f:	00 
  801790:	c7 04 24 ec 33 80 00 	movl   $0x8033ec,(%esp)
  801797:	e8 00 ec ff ff       	call   80039c <_panic>
}
  80179c:	83 c4 3c             	add    $0x3c,%esp
  80179f:	5b                   	pop    %ebx
  8017a0:	5e                   	pop    %esi
  8017a1:	5f                   	pop    %edi
  8017a2:	5d                   	pop    %ebp
  8017a3:	c3                   	ret    
	...

008017b0 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  8017b0:	55                   	push   %ebp
  8017b1:	89 e5                	mov    %esp,%ebp
  8017b3:	57                   	push   %edi
  8017b4:	56                   	push   %esi
  8017b5:	53                   	push   %ebx
  8017b6:	83 ec 2c             	sub    $0x2c,%esp
  8017b9:	8b 75 08             	mov    0x8(%ebp),%esi
  8017bc:	8b 7d 0c             	mov    0xc(%ebp),%edi
  8017bf:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  8017c2:	85 db                	test   %ebx,%ebx
  8017c4:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  8017c9:	0f 45 c3             	cmovne %ebx,%eax
  8017cc:	8b 55 14             	mov    0x14(%ebp),%edx
  8017cf:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8017d3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8017d7:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8017db:	89 34 24             	mov    %esi,(%esp)
  8017de:	e8 6d f8 ff ff       	call   801050 <sys_ipc_try_send>
  8017e3:	83 f8 f9             	cmp    $0xfffffff9,%eax
  8017e6:	75 0a                	jne    8017f2 <ipc_send+0x42>
      sys_yield();
  8017e8:	e8 f8 fa ff ff       	call   8012e5 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  8017ed:	8d 76 00             	lea    0x0(%esi),%esi
  8017f0:	eb d0                	jmp    8017c2 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  8017f2:	85 c0                	test   %eax,%eax
  8017f4:	79 24                	jns    80181a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  8017f6:	89 44 24 10          	mov    %eax,0x10(%esp)
  8017fa:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8017fe:	c7 44 24 08 98 35 80 	movl   $0x803598,0x8(%esp)
  801805:	00 
  801806:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  80180d:	00 
  80180e:	c7 04 24 bc 35 80 00 	movl   $0x8035bc,(%esp)
  801815:	e8 82 eb ff ff       	call   80039c <_panic>
    else
      return;
  }
}
  80181a:	83 c4 2c             	add    $0x2c,%esp
  80181d:	5b                   	pop    %ebx
  80181e:	5e                   	pop    %esi
  80181f:	5f                   	pop    %edi
  801820:	5d                   	pop    %ebp
  801821:	c3                   	ret    

00801822 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  801822:	55                   	push   %ebp
  801823:	89 e5                	mov    %esp,%ebp
  801825:	56                   	push   %esi
  801826:	53                   	push   %ebx
  801827:	83 ec 10             	sub    $0x10,%esp
  80182a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80182d:	8b 45 0c             	mov    0xc(%ebp),%eax
  801830:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  801833:	85 c0                	test   %eax,%eax
  801835:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  80183a:	0f 44 c2             	cmove  %edx,%eax
  80183d:	89 04 24             	mov    %eax,(%esp)
  801840:	e8 ae f7 ff ff       	call   800ff3 <sys_ipc_recv>
  801845:	85 c0                	test   %eax,%eax
  801847:	78 24                	js     80186d <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  801849:	85 db                	test   %ebx,%ebx
  80184b:	74 0a                	je     801857 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  80184d:	a1 78 70 80 00       	mov    0x807078,%eax
  801852:	8b 40 74             	mov    0x74(%eax),%eax
  801855:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  801857:	85 f6                	test   %esi,%esi
  801859:	74 0a                	je     801865 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  80185b:	a1 78 70 80 00       	mov    0x807078,%eax
  801860:	8b 40 78             	mov    0x78(%eax),%eax
  801863:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  801865:	a1 78 70 80 00       	mov    0x807078,%eax
  80186a:	8b 40 70             	mov    0x70(%eax),%eax
}
  80186d:	83 c4 10             	add    $0x10,%esp
  801870:	5b                   	pop    %ebx
  801871:	5e                   	pop    %esi
  801872:	5d                   	pop    %ebp
  801873:	c3                   	ret    
	...

00801880 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801880:	55                   	push   %ebp
  801881:	89 e5                	mov    %esp,%ebp
  801883:	8b 45 08             	mov    0x8(%ebp),%eax
  801886:	05 00 00 00 30       	add    $0x30000000,%eax
  80188b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80188e:	5d                   	pop    %ebp
  80188f:	c3                   	ret    

00801890 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801890:	55                   	push   %ebp
  801891:	89 e5                	mov    %esp,%ebp
  801893:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801896:	8b 45 08             	mov    0x8(%ebp),%eax
  801899:	89 04 24             	mov    %eax,(%esp)
  80189c:	e8 df ff ff ff       	call   801880 <fd2num>
  8018a1:	05 20 00 0d 00       	add    $0xd0020,%eax
  8018a6:	c1 e0 0c             	shl    $0xc,%eax
}
  8018a9:	c9                   	leave  
  8018aa:	c3                   	ret    

008018ab <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  8018ab:	55                   	push   %ebp
  8018ac:	89 e5                	mov    %esp,%ebp
  8018ae:	57                   	push   %edi
  8018af:	56                   	push   %esi
  8018b0:	53                   	push   %ebx
  8018b1:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  8018b4:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  8018b9:	a8 01                	test   $0x1,%al
  8018bb:	74 36                	je     8018f3 <fd_alloc+0x48>
  8018bd:	a1 00 00 74 ef       	mov    0xef740000,%eax
  8018c2:	a8 01                	test   $0x1,%al
  8018c4:	74 2d                	je     8018f3 <fd_alloc+0x48>
  8018c6:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  8018cb:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  8018d0:	be 00 00 40 ef       	mov    $0xef400000,%esi
  8018d5:	89 c3                	mov    %eax,%ebx
  8018d7:	89 c2                	mov    %eax,%edx
  8018d9:	c1 ea 16             	shr    $0x16,%edx
  8018dc:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  8018df:	f6 c2 01             	test   $0x1,%dl
  8018e2:	74 14                	je     8018f8 <fd_alloc+0x4d>
  8018e4:	89 c2                	mov    %eax,%edx
  8018e6:	c1 ea 0c             	shr    $0xc,%edx
  8018e9:	8b 14 96             	mov    (%esi,%edx,4),%edx
  8018ec:	f6 c2 01             	test   $0x1,%dl
  8018ef:	75 10                	jne    801901 <fd_alloc+0x56>
  8018f1:	eb 05                	jmp    8018f8 <fd_alloc+0x4d>
  8018f3:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  8018f8:	89 1f                	mov    %ebx,(%edi)
  8018fa:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8018ff:	eb 17                	jmp    801918 <fd_alloc+0x6d>
  801901:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  801906:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  80190b:	75 c8                	jne    8018d5 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  80190d:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  801913:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  801918:	5b                   	pop    %ebx
  801919:	5e                   	pop    %esi
  80191a:	5f                   	pop    %edi
  80191b:	5d                   	pop    %ebp
  80191c:	c3                   	ret    

0080191d <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  80191d:	55                   	push   %ebp
  80191e:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801920:	8b 45 08             	mov    0x8(%ebp),%eax
  801923:	83 f8 1f             	cmp    $0x1f,%eax
  801926:	77 36                	ja     80195e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801928:	05 00 00 0d 00       	add    $0xd0000,%eax
  80192d:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801930:	89 c2                	mov    %eax,%edx
  801932:	c1 ea 16             	shr    $0x16,%edx
  801935:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80193c:	f6 c2 01             	test   $0x1,%dl
  80193f:	74 1d                	je     80195e <fd_lookup+0x41>
  801941:	89 c2                	mov    %eax,%edx
  801943:	c1 ea 0c             	shr    $0xc,%edx
  801946:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  80194d:	f6 c2 01             	test   $0x1,%dl
  801950:	74 0c                	je     80195e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  801952:	8b 55 0c             	mov    0xc(%ebp),%edx
  801955:	89 02                	mov    %eax,(%edx)
  801957:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  80195c:	eb 05                	jmp    801963 <fd_lookup+0x46>
  80195e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801963:	5d                   	pop    %ebp
  801964:	c3                   	ret    

00801965 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801965:	55                   	push   %ebp
  801966:	89 e5                	mov    %esp,%ebp
  801968:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80196b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80196e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801972:	8b 45 08             	mov    0x8(%ebp),%eax
  801975:	89 04 24             	mov    %eax,(%esp)
  801978:	e8 a0 ff ff ff       	call   80191d <fd_lookup>
  80197d:	85 c0                	test   %eax,%eax
  80197f:	78 0e                	js     80198f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801981:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801984:	8b 55 0c             	mov    0xc(%ebp),%edx
  801987:	89 50 04             	mov    %edx,0x4(%eax)
  80198a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80198f:	c9                   	leave  
  801990:	c3                   	ret    

00801991 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801991:	55                   	push   %ebp
  801992:	89 e5                	mov    %esp,%ebp
  801994:	56                   	push   %esi
  801995:	53                   	push   %ebx
  801996:	83 ec 10             	sub    $0x10,%esp
  801999:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80199c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80199f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  8019a4:	b8 04 70 80 00       	mov    $0x807004,%eax
  8019a9:	39 0d 04 70 80 00    	cmp    %ecx,0x807004
  8019af:	75 11                	jne    8019c2 <dev_lookup+0x31>
  8019b1:	eb 04                	jmp    8019b7 <dev_lookup+0x26>
  8019b3:	39 08                	cmp    %ecx,(%eax)
  8019b5:	75 10                	jne    8019c7 <dev_lookup+0x36>
			*dev = devtab[i];
  8019b7:	89 03                	mov    %eax,(%ebx)
  8019b9:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8019be:	66 90                	xchg   %ax,%ax
  8019c0:	eb 36                	jmp    8019f8 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  8019c2:	be 44 36 80 00       	mov    $0x803644,%esi
  8019c7:	83 c2 01             	add    $0x1,%edx
  8019ca:	8b 04 96             	mov    (%esi,%edx,4),%eax
  8019cd:	85 c0                	test   %eax,%eax
  8019cf:	75 e2                	jne    8019b3 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  8019d1:	a1 78 70 80 00       	mov    0x807078,%eax
  8019d6:	8b 40 4c             	mov    0x4c(%eax),%eax
  8019d9:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8019dd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019e1:	c7 04 24 c8 35 80 00 	movl   $0x8035c8,(%esp)
  8019e8:	e8 74 ea ff ff       	call   800461 <cprintf>
	*dev = 0;
  8019ed:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8019f3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  8019f8:	83 c4 10             	add    $0x10,%esp
  8019fb:	5b                   	pop    %ebx
  8019fc:	5e                   	pop    %esi
  8019fd:	5d                   	pop    %ebp
  8019fe:	c3                   	ret    

008019ff <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  8019ff:	55                   	push   %ebp
  801a00:	89 e5                	mov    %esp,%ebp
  801a02:	53                   	push   %ebx
  801a03:	83 ec 24             	sub    $0x24,%esp
  801a06:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a09:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801a0c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a10:	8b 45 08             	mov    0x8(%ebp),%eax
  801a13:	89 04 24             	mov    %eax,(%esp)
  801a16:	e8 02 ff ff ff       	call   80191d <fd_lookup>
  801a1b:	85 c0                	test   %eax,%eax
  801a1d:	78 53                	js     801a72 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801a1f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a22:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a26:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801a29:	8b 00                	mov    (%eax),%eax
  801a2b:	89 04 24             	mov    %eax,(%esp)
  801a2e:	e8 5e ff ff ff       	call   801991 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a33:	85 c0                	test   %eax,%eax
  801a35:	78 3b                	js     801a72 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801a37:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801a3c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801a3f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  801a43:	74 2d                	je     801a72 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801a45:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801a48:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  801a4f:	00 00 00 
	stat->st_isdir = 0;
  801a52:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801a59:	00 00 00 
	stat->st_dev = dev;
  801a5c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801a5f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801a65:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801a69:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801a6c:	89 14 24             	mov    %edx,(%esp)
  801a6f:	ff 50 14             	call   *0x14(%eax)
}
  801a72:	83 c4 24             	add    $0x24,%esp
  801a75:	5b                   	pop    %ebx
  801a76:	5d                   	pop    %ebp
  801a77:	c3                   	ret    

00801a78 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801a78:	55                   	push   %ebp
  801a79:	89 e5                	mov    %esp,%ebp
  801a7b:	53                   	push   %ebx
  801a7c:	83 ec 24             	sub    $0x24,%esp
  801a7f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a82:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801a85:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a89:	89 1c 24             	mov    %ebx,(%esp)
  801a8c:	e8 8c fe ff ff       	call   80191d <fd_lookup>
  801a91:	85 c0                	test   %eax,%eax
  801a93:	78 5f                	js     801af4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801a95:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a98:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a9c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801a9f:	8b 00                	mov    (%eax),%eax
  801aa1:	89 04 24             	mov    %eax,(%esp)
  801aa4:	e8 e8 fe ff ff       	call   801991 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801aa9:	85 c0                	test   %eax,%eax
  801aab:	78 47                	js     801af4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801aad:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801ab0:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801ab4:	75 23                	jne    801ad9 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801ab6:	a1 78 70 80 00       	mov    0x807078,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  801abb:	8b 40 4c             	mov    0x4c(%eax),%eax
  801abe:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801ac2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ac6:	c7 04 24 e8 35 80 00 	movl   $0x8035e8,(%esp)
  801acd:	e8 8f e9 ff ff       	call   800461 <cprintf>
  801ad2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  801ad7:	eb 1b                	jmp    801af4 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  801ad9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801adc:	8b 48 18             	mov    0x18(%eax),%ecx
  801adf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801ae4:	85 c9                	test   %ecx,%ecx
  801ae6:	74 0c                	je     801af4 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801ae8:	8b 45 0c             	mov    0xc(%ebp),%eax
  801aeb:	89 44 24 04          	mov    %eax,0x4(%esp)
  801aef:	89 14 24             	mov    %edx,(%esp)
  801af2:	ff d1                	call   *%ecx
}
  801af4:	83 c4 24             	add    $0x24,%esp
  801af7:	5b                   	pop    %ebx
  801af8:	5d                   	pop    %ebp
  801af9:	c3                   	ret    

00801afa <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  801afa:	55                   	push   %ebp
  801afb:	89 e5                	mov    %esp,%ebp
  801afd:	53                   	push   %ebx
  801afe:	83 ec 24             	sub    $0x24,%esp
  801b01:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801b04:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801b07:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b0b:	89 1c 24             	mov    %ebx,(%esp)
  801b0e:	e8 0a fe ff ff       	call   80191d <fd_lookup>
  801b13:	85 c0                	test   %eax,%eax
  801b15:	78 66                	js     801b7d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801b17:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801b1a:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b1e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801b21:	8b 00                	mov    (%eax),%eax
  801b23:	89 04 24             	mov    %eax,(%esp)
  801b26:	e8 66 fe ff ff       	call   801991 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801b2b:	85 c0                	test   %eax,%eax
  801b2d:	78 4e                	js     801b7d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801b2f:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801b32:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801b36:	75 23                	jne    801b5b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801b38:	a1 78 70 80 00       	mov    0x807078,%eax
  801b3d:	8b 40 4c             	mov    0x4c(%eax),%eax
  801b40:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801b44:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b48:	c7 04 24 09 36 80 00 	movl   $0x803609,(%esp)
  801b4f:	e8 0d e9 ff ff       	call   800461 <cprintf>
  801b54:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801b59:	eb 22                	jmp    801b7d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  801b5b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801b5e:	8b 48 0c             	mov    0xc(%eax),%ecx
  801b61:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801b66:	85 c9                	test   %ecx,%ecx
  801b68:	74 13                	je     801b7d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  801b6a:	8b 45 10             	mov    0x10(%ebp),%eax
  801b6d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801b71:	8b 45 0c             	mov    0xc(%ebp),%eax
  801b74:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b78:	89 14 24             	mov    %edx,(%esp)
  801b7b:	ff d1                	call   *%ecx
}
  801b7d:	83 c4 24             	add    $0x24,%esp
  801b80:	5b                   	pop    %ebx
  801b81:	5d                   	pop    %ebp
  801b82:	c3                   	ret    

00801b83 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801b83:	55                   	push   %ebp
  801b84:	89 e5                	mov    %esp,%ebp
  801b86:	57                   	push   %edi
  801b87:	56                   	push   %esi
  801b88:	53                   	push   %ebx
  801b89:	83 ec 2c             	sub    $0x2c,%esp
  801b8c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  801b8f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801b92:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801b95:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b99:	89 1c 24             	mov    %ebx,(%esp)
  801b9c:	e8 7c fd ff ff       	call   80191d <fd_lookup>
  801ba1:	85 c0                	test   %eax,%eax
  801ba3:	0f 88 b0 00 00 00    	js     801c59 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801ba9:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801bac:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bb0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801bb3:	8b 00                	mov    (%eax),%eax
  801bb5:	89 04 24             	mov    %eax,(%esp)
  801bb8:	e8 d4 fd ff ff       	call   801991 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801bbd:	85 c0                	test   %eax,%eax
  801bbf:	0f 88 94 00 00 00    	js     801c59 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801bc5:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801bc8:	8b 40 08             	mov    0x8(%eax),%eax
  801bcb:	83 e0 03             	and    $0x3,%eax
  801bce:	83 f8 01             	cmp    $0x1,%eax
  801bd1:	75 23                	jne    801bf6 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801bd3:	a1 78 70 80 00       	mov    0x807078,%eax
  801bd8:	8b 40 4c             	mov    0x4c(%eax),%eax
  801bdb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801bdf:	89 44 24 04          	mov    %eax,0x4(%esp)
  801be3:	c7 04 24 26 36 80 00 	movl   $0x803626,(%esp)
  801bea:	e8 72 e8 ff ff       	call   800461 <cprintf>
  801bef:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801bf4:	eb 63                	jmp    801c59 <read+0xd6>
	}
	if (!dev->dev_read)
  801bf6:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801bfb:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801bfe:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  801c02:	74 55                	je     801c59 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801c04:	ba 00 00 00 00       	mov    $0x0,%edx
  801c09:	bb 00 00 00 00       	mov    $0x0,%ebx
  801c0e:	b8 00 00 00 00       	mov    $0x0,%eax
  801c13:	85 f6                	test   %esi,%esi
  801c15:	74 42                	je     801c59 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801c17:	bf 00 10 00 00       	mov    $0x1000,%edi
  801c1c:	89 f0                	mov    %esi,%eax
  801c1e:	29 d0                	sub    %edx,%eax
  801c20:	89 c1                	mov    %eax,%ecx
  801c22:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  801c28:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801c2d:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801c30:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801c34:	03 55 0c             	add    0xc(%ebp),%edx
  801c37:	89 54 24 04          	mov    %edx,0x4(%esp)
  801c3b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801c3e:	89 04 24             	mov    %eax,(%esp)
  801c41:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801c44:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  801c47:	85 c0                	test   %eax,%eax
  801c49:	78 0e                	js     801c59 <read+0xd6>
			return m;
		if (m == 0)
  801c4b:	85 c0                	test   %eax,%eax
  801c4d:	74 08                	je     801c57 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801c4f:	01 c3                	add    %eax,%ebx
  801c51:	89 da                	mov    %ebx,%edx
  801c53:	39 f3                	cmp    %esi,%ebx
  801c55:	72 c5                	jb     801c1c <read+0x99>
  801c57:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801c59:	83 c4 2c             	add    $0x2c,%esp
  801c5c:	5b                   	pop    %ebx
  801c5d:	5e                   	pop    %esi
  801c5e:	5f                   	pop    %edi
  801c5f:	5d                   	pop    %ebp
  801c60:	c3                   	ret    

00801c61 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801c61:	55                   	push   %ebp
  801c62:	89 e5                	mov    %esp,%ebp
  801c64:	57                   	push   %edi
  801c65:	56                   	push   %esi
  801c66:	53                   	push   %ebx
  801c67:	83 ec 1c             	sub    $0x1c,%esp
  801c6a:	8b 7d 08             	mov    0x8(%ebp),%edi
  801c6d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801c70:	ba 00 00 00 00       	mov    $0x0,%edx
  801c75:	bb 00 00 00 00       	mov    $0x0,%ebx
  801c7a:	b8 00 00 00 00       	mov    $0x0,%eax
  801c7f:	85 f6                	test   %esi,%esi
  801c81:	74 29                	je     801cac <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801c83:	89 f0                	mov    %esi,%eax
  801c85:	29 d0                	sub    %edx,%eax
  801c87:	89 44 24 08          	mov    %eax,0x8(%esp)
  801c8b:	03 55 0c             	add    0xc(%ebp),%edx
  801c8e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801c92:	89 3c 24             	mov    %edi,(%esp)
  801c95:	e8 e9 fe ff ff       	call   801b83 <read>
		if (m < 0)
  801c9a:	85 c0                	test   %eax,%eax
  801c9c:	78 0e                	js     801cac <readn+0x4b>
			return m;
		if (m == 0)
  801c9e:	85 c0                	test   %eax,%eax
  801ca0:	74 08                	je     801caa <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801ca2:	01 c3                	add    %eax,%ebx
  801ca4:	89 da                	mov    %ebx,%edx
  801ca6:	39 f3                	cmp    %esi,%ebx
  801ca8:	72 d9                	jb     801c83 <readn+0x22>
  801caa:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801cac:	83 c4 1c             	add    $0x1c,%esp
  801caf:	5b                   	pop    %ebx
  801cb0:	5e                   	pop    %esi
  801cb1:	5f                   	pop    %edi
  801cb2:	5d                   	pop    %ebp
  801cb3:	c3                   	ret    

00801cb4 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801cb4:	55                   	push   %ebp
  801cb5:	89 e5                	mov    %esp,%ebp
  801cb7:	83 ec 28             	sub    $0x28,%esp
  801cba:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801cbd:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801cc0:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801cc3:	89 34 24             	mov    %esi,(%esp)
  801cc6:	e8 b5 fb ff ff       	call   801880 <fd2num>
  801ccb:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801cce:	89 54 24 04          	mov    %edx,0x4(%esp)
  801cd2:	89 04 24             	mov    %eax,(%esp)
  801cd5:	e8 43 fc ff ff       	call   80191d <fd_lookup>
  801cda:	89 c3                	mov    %eax,%ebx
  801cdc:	85 c0                	test   %eax,%eax
  801cde:	78 05                	js     801ce5 <fd_close+0x31>
  801ce0:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801ce3:	74 0e                	je     801cf3 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801ce5:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801ce9:	b8 00 00 00 00       	mov    $0x0,%eax
  801cee:	0f 44 d8             	cmove  %eax,%ebx
  801cf1:	eb 3d                	jmp    801d30 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801cf3:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801cf6:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cfa:	8b 06                	mov    (%esi),%eax
  801cfc:	89 04 24             	mov    %eax,(%esp)
  801cff:	e8 8d fc ff ff       	call   801991 <dev_lookup>
  801d04:	89 c3                	mov    %eax,%ebx
  801d06:	85 c0                	test   %eax,%eax
  801d08:	78 16                	js     801d20 <fd_close+0x6c>
		if (dev->dev_close)
  801d0a:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801d0d:	8b 40 10             	mov    0x10(%eax),%eax
  801d10:	bb 00 00 00 00       	mov    $0x0,%ebx
  801d15:	85 c0                	test   %eax,%eax
  801d17:	74 07                	je     801d20 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801d19:	89 34 24             	mov    %esi,(%esp)
  801d1c:	ff d0                	call   *%eax
  801d1e:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  801d20:	89 74 24 04          	mov    %esi,0x4(%esp)
  801d24:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d2b:	e8 9a f4 ff ff       	call   8011ca <sys_page_unmap>
	return r;
}
  801d30:	89 d8                	mov    %ebx,%eax
  801d32:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801d35:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801d38:	89 ec                	mov    %ebp,%esp
  801d3a:	5d                   	pop    %ebp
  801d3b:	c3                   	ret    

00801d3c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  801d3c:	55                   	push   %ebp
  801d3d:	89 e5                	mov    %esp,%ebp
  801d3f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801d42:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d45:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d49:	8b 45 08             	mov    0x8(%ebp),%eax
  801d4c:	89 04 24             	mov    %eax,(%esp)
  801d4f:	e8 c9 fb ff ff       	call   80191d <fd_lookup>
  801d54:	85 c0                	test   %eax,%eax
  801d56:	78 13                	js     801d6b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  801d58:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801d5f:	00 
  801d60:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d63:	89 04 24             	mov    %eax,(%esp)
  801d66:	e8 49 ff ff ff       	call   801cb4 <fd_close>
}
  801d6b:	c9                   	leave  
  801d6c:	c3                   	ret    

00801d6d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  801d6d:	55                   	push   %ebp
  801d6e:	89 e5                	mov    %esp,%ebp
  801d70:	83 ec 18             	sub    $0x18,%esp
  801d73:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801d76:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801d79:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801d80:	00 
  801d81:	8b 45 08             	mov    0x8(%ebp),%eax
  801d84:	89 04 24             	mov    %eax,(%esp)
  801d87:	e8 80 03 00 00       	call   80210c <open>
  801d8c:	89 c3                	mov    %eax,%ebx
  801d8e:	85 c0                	test   %eax,%eax
  801d90:	78 1b                	js     801dad <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801d92:	8b 45 0c             	mov    0xc(%ebp),%eax
  801d95:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d99:	89 1c 24             	mov    %ebx,(%esp)
  801d9c:	e8 5e fc ff ff       	call   8019ff <fstat>
  801da1:	89 c6                	mov    %eax,%esi
	close(fd);
  801da3:	89 1c 24             	mov    %ebx,(%esp)
  801da6:	e8 91 ff ff ff       	call   801d3c <close>
  801dab:	89 f3                	mov    %esi,%ebx
	return r;
}
  801dad:	89 d8                	mov    %ebx,%eax
  801daf:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801db2:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801db5:	89 ec                	mov    %ebp,%esp
  801db7:	5d                   	pop    %ebp
  801db8:	c3                   	ret    

00801db9 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801db9:	55                   	push   %ebp
  801dba:	89 e5                	mov    %esp,%ebp
  801dbc:	53                   	push   %ebx
  801dbd:	83 ec 14             	sub    $0x14,%esp
  801dc0:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801dc5:	89 1c 24             	mov    %ebx,(%esp)
  801dc8:	e8 6f ff ff ff       	call   801d3c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  801dcd:	83 c3 01             	add    $0x1,%ebx
  801dd0:	83 fb 20             	cmp    $0x20,%ebx
  801dd3:	75 f0                	jne    801dc5 <close_all+0xc>
		close(i);
}
  801dd5:	83 c4 14             	add    $0x14,%esp
  801dd8:	5b                   	pop    %ebx
  801dd9:	5d                   	pop    %ebp
  801dda:	c3                   	ret    

00801ddb <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801ddb:	55                   	push   %ebp
  801ddc:	89 e5                	mov    %esp,%ebp
  801dde:	83 ec 58             	sub    $0x58,%esp
  801de1:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801de4:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801de7:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801dea:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801ded:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801df0:	89 44 24 04          	mov    %eax,0x4(%esp)
  801df4:	8b 45 08             	mov    0x8(%ebp),%eax
  801df7:	89 04 24             	mov    %eax,(%esp)
  801dfa:	e8 1e fb ff ff       	call   80191d <fd_lookup>
  801dff:	89 c3                	mov    %eax,%ebx
  801e01:	85 c0                	test   %eax,%eax
  801e03:	0f 88 e0 00 00 00    	js     801ee9 <dup+0x10e>
		return r;
	close(newfdnum);
  801e09:	89 3c 24             	mov    %edi,(%esp)
  801e0c:	e8 2b ff ff ff       	call   801d3c <close>

	newfd = INDEX2FD(newfdnum);
  801e11:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801e17:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  801e1a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801e1d:	89 04 24             	mov    %eax,(%esp)
  801e20:	e8 6b fa ff ff       	call   801890 <fd2data>
  801e25:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801e27:	89 34 24             	mov    %esi,(%esp)
  801e2a:	e8 61 fa ff ff       	call   801890 <fd2data>
  801e2f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801e32:	89 da                	mov    %ebx,%edx
  801e34:	89 d8                	mov    %ebx,%eax
  801e36:	c1 e8 16             	shr    $0x16,%eax
  801e39:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801e40:	a8 01                	test   $0x1,%al
  801e42:	74 43                	je     801e87 <dup+0xac>
  801e44:	c1 ea 0c             	shr    $0xc,%edx
  801e47:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801e4e:	a8 01                	test   $0x1,%al
  801e50:	74 35                	je     801e87 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801e52:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801e59:	25 07 0e 00 00       	and    $0xe07,%eax
  801e5e:	89 44 24 10          	mov    %eax,0x10(%esp)
  801e62:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801e65:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801e69:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801e70:	00 
  801e71:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801e75:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801e7c:	e8 a7 f3 ff ff       	call   801228 <sys_page_map>
  801e81:	89 c3                	mov    %eax,%ebx
  801e83:	85 c0                	test   %eax,%eax
  801e85:	78 3f                	js     801ec6 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801e87:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801e8a:	89 c2                	mov    %eax,%edx
  801e8c:	c1 ea 0c             	shr    $0xc,%edx
  801e8f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801e96:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  801e9c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801ea0:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801ea4:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801eab:	00 
  801eac:	89 44 24 04          	mov    %eax,0x4(%esp)
  801eb0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801eb7:	e8 6c f3 ff ff       	call   801228 <sys_page_map>
  801ebc:	89 c3                	mov    %eax,%ebx
  801ebe:	85 c0                	test   %eax,%eax
  801ec0:	78 04                	js     801ec6 <dup+0xeb>
  801ec2:	89 fb                	mov    %edi,%ebx
  801ec4:	eb 23                	jmp    801ee9 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801ec6:	89 74 24 04          	mov    %esi,0x4(%esp)
  801eca:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801ed1:	e8 f4 f2 ff ff       	call   8011ca <sys_page_unmap>
	sys_page_unmap(0, nva);
  801ed6:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801ed9:	89 44 24 04          	mov    %eax,0x4(%esp)
  801edd:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801ee4:	e8 e1 f2 ff ff       	call   8011ca <sys_page_unmap>
	return r;
}
  801ee9:	89 d8                	mov    %ebx,%eax
  801eeb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801eee:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801ef1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801ef4:	89 ec                	mov    %ebp,%esp
  801ef6:	5d                   	pop    %ebp
  801ef7:	c3                   	ret    

00801ef8 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801ef8:	55                   	push   %ebp
  801ef9:	89 e5                	mov    %esp,%ebp
  801efb:	53                   	push   %ebx
  801efc:	83 ec 14             	sub    $0x14,%esp
  801eff:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801f01:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801f07:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801f0e:	00 
  801f0f:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801f16:	00 
  801f17:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f1b:	89 14 24             	mov    %edx,(%esp)
  801f1e:	e8 8d f8 ff ff       	call   8017b0 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801f23:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801f2a:	00 
  801f2b:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801f2f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801f36:	e8 e7 f8 ff ff       	call   801822 <ipc_recv>
}
  801f3b:	83 c4 14             	add    $0x14,%esp
  801f3e:	5b                   	pop    %ebx
  801f3f:	5d                   	pop    %ebp
  801f40:	c3                   	ret    

00801f41 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801f41:	55                   	push   %ebp
  801f42:	89 e5                	mov    %esp,%ebp
  801f44:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801f47:	8b 45 08             	mov    0x8(%ebp),%eax
  801f4a:	8b 40 0c             	mov    0xc(%eax),%eax
  801f4d:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  801f52:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f55:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801f5a:	ba 00 00 00 00       	mov    $0x0,%edx
  801f5f:	b8 02 00 00 00       	mov    $0x2,%eax
  801f64:	e8 8f ff ff ff       	call   801ef8 <fsipc>
}
  801f69:	c9                   	leave  
  801f6a:	c3                   	ret    

00801f6b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  801f6b:	55                   	push   %ebp
  801f6c:	89 e5                	mov    %esp,%ebp
  801f6e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801f71:	8b 45 08             	mov    0x8(%ebp),%eax
  801f74:	8b 40 0c             	mov    0xc(%eax),%eax
  801f77:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  801f7c:	ba 00 00 00 00       	mov    $0x0,%edx
  801f81:	b8 06 00 00 00       	mov    $0x6,%eax
  801f86:	e8 6d ff ff ff       	call   801ef8 <fsipc>
}
  801f8b:	c9                   	leave  
  801f8c:	c3                   	ret    

00801f8d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  801f8d:	55                   	push   %ebp
  801f8e:	89 e5                	mov    %esp,%ebp
  801f90:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801f93:	ba 00 00 00 00       	mov    $0x0,%edx
  801f98:	b8 08 00 00 00       	mov    $0x8,%eax
  801f9d:	e8 56 ff ff ff       	call   801ef8 <fsipc>
}
  801fa2:	c9                   	leave  
  801fa3:	c3                   	ret    

00801fa4 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801fa4:	55                   	push   %ebp
  801fa5:	89 e5                	mov    %esp,%ebp
  801fa7:	53                   	push   %ebx
  801fa8:	83 ec 14             	sub    $0x14,%esp
  801fab:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801fae:	8b 45 08             	mov    0x8(%ebp),%eax
  801fb1:	8b 40 0c             	mov    0xc(%eax),%eax
  801fb4:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801fb9:	ba 00 00 00 00       	mov    $0x0,%edx
  801fbe:	b8 05 00 00 00       	mov    $0x5,%eax
  801fc3:	e8 30 ff ff ff       	call   801ef8 <fsipc>
  801fc8:	85 c0                	test   %eax,%eax
  801fca:	78 2b                	js     801ff7 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801fcc:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801fd3:	00 
  801fd4:	89 1c 24             	mov    %ebx,(%esp)
  801fd7:	e8 4e eb ff ff       	call   800b2a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801fdc:	a1 80 40 80 00       	mov    0x804080,%eax
  801fe1:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801fe7:	a1 84 40 80 00       	mov    0x804084,%eax
  801fec:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801ff2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801ff7:	83 c4 14             	add    $0x14,%esp
  801ffa:	5b                   	pop    %ebx
  801ffb:	5d                   	pop    %ebp
  801ffc:	c3                   	ret    

00801ffd <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  801ffd:	55                   	push   %ebp
  801ffe:	89 e5                	mov    %esp,%ebp
  802000:	53                   	push   %ebx
  802001:	83 ec 14             	sub    $0x14,%esp
  802004:	8b 45 08             	mov    0x8(%ebp),%eax
  802007:	8b 55 0c             	mov    0xc(%ebp),%edx
  80200a:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  80200d:	85 c0                	test   %eax,%eax
  80200f:	74 44                	je     802055 <devfile_write+0x58>
  802011:	85 d2                	test   %edx,%edx
  802013:	74 40                	je     802055 <devfile_write+0x58>
  802015:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  80201b:	77 38                	ja     802055 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  80201d:	8b 40 0c             	mov    0xc(%eax),%eax
  802020:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  802025:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  80202b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80202f:	89 54 24 04          	mov    %edx,0x4(%esp)
  802033:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  80203a:	e8 a6 ec ff ff       	call   800ce5 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  80203f:	ba 00 00 00 00       	mov    $0x0,%edx
  802044:	b8 04 00 00 00       	mov    $0x4,%eax
  802049:	e8 aa fe ff ff       	call   801ef8 <fsipc>
        return r;
    return n;
  80204e:	85 c0                	test   %eax,%eax
  802050:	0f 49 c3             	cmovns %ebx,%eax
  802053:	eb 05                	jmp    80205a <devfile_write+0x5d>
  802055:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  80205a:	83 c4 14             	add    $0x14,%esp
  80205d:	5b                   	pop    %ebx
  80205e:	5d                   	pop    %ebp
  80205f:	c3                   	ret    

00802060 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  802060:	55                   	push   %ebp
  802061:	89 e5                	mov    %esp,%ebp
  802063:	83 ec 18             	sub    $0x18,%esp
  802066:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802069:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80206c:	8b 45 08             	mov    0x8(%ebp),%eax
  80206f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  802072:	85 c0                	test   %eax,%eax
  802074:	74 04                	je     80207a <devfile_read+0x1a>
  802076:	85 f6                	test   %esi,%esi
  802078:	75 07                	jne    802081 <devfile_read+0x21>
  80207a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  80207f:	eb 39                	jmp    8020ba <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  802081:	8b 40 0c             	mov    0xc(%eax),%eax
  802084:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  802089:	8b 45 10             	mov    0x10(%ebp),%eax
  80208c:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  802091:	ba 00 00 00 00       	mov    $0x0,%edx
  802096:	b8 03 00 00 00       	mov    $0x3,%eax
  80209b:	e8 58 fe ff ff       	call   801ef8 <fsipc>
  8020a0:	89 c3                	mov    %eax,%ebx
  8020a2:	85 c0                	test   %eax,%eax
  8020a4:	78 14                	js     8020ba <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  8020a6:	89 44 24 08          	mov    %eax,0x8(%esp)
  8020aa:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  8020b1:	00 
  8020b2:	89 34 24             	mov    %esi,(%esp)
  8020b5:	e8 2b ec ff ff       	call   800ce5 <memmove>
  return r;
}
  8020ba:	89 d8                	mov    %ebx,%eax
  8020bc:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8020bf:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8020c2:	89 ec                	mov    %ebp,%esp
  8020c4:	5d                   	pop    %ebp
  8020c5:	c3                   	ret    

008020c6 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  8020c6:	55                   	push   %ebp
  8020c7:	89 e5                	mov    %esp,%ebp
  8020c9:	53                   	push   %ebx
  8020ca:	83 ec 14             	sub    $0x14,%esp
  8020cd:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  8020d0:	89 1c 24             	mov    %ebx,(%esp)
  8020d3:	e8 08 ea ff ff       	call   800ae0 <strlen>
  8020d8:	89 c2                	mov    %eax,%edx
  8020da:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  8020df:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  8020e5:	7f 1f                	jg     802106 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  8020e7:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8020eb:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  8020f2:	e8 33 ea ff ff       	call   800b2a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  8020f7:	ba 00 00 00 00       	mov    $0x0,%edx
  8020fc:	b8 07 00 00 00       	mov    $0x7,%eax
  802101:	e8 f2 fd ff ff       	call   801ef8 <fsipc>
}
  802106:	83 c4 14             	add    $0x14,%esp
  802109:	5b                   	pop    %ebx
  80210a:	5d                   	pop    %ebp
  80210b:	c3                   	ret    

0080210c <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  80210c:	55                   	push   %ebp
  80210d:	89 e5                	mov    %esp,%ebp
  80210f:	83 ec 28             	sub    $0x28,%esp
  802112:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802115:	89 75 fc             	mov    %esi,-0x4(%ebp)
  802118:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  80211b:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  802120:	85 f6                	test   %esi,%esi
  802122:	74 65                	je     802189 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  802124:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  80212b:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80212e:	89 04 24             	mov    %eax,(%esp)
  802131:	e8 75 f7 ff ff       	call   8018ab <fd_alloc>
  802136:	89 c3                	mov    %eax,%ebx
  802138:	85 c0                	test   %eax,%eax
  80213a:	78 4d                	js     802189 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  80213c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802140:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  802147:	e8 de e9 ff ff       	call   800b2a <strcpy>
	fsipcbuf.open.req_omode = mode;
  80214c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80214f:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  802154:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802157:	b8 01 00 00 00       	mov    $0x1,%eax
  80215c:	e8 97 fd ff ff       	call   801ef8 <fsipc>
  802161:	89 c3                	mov    %eax,%ebx
  802163:	85 c0                	test   %eax,%eax
  802165:	79 15                	jns    80217c <open+0x70>
    fd_close(f, 0);
  802167:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80216e:	00 
  80216f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802172:	89 04 24             	mov    %eax,(%esp)
  802175:	e8 3a fb ff ff       	call   801cb4 <fd_close>
    return r;
  80217a:	eb 0d                	jmp    802189 <open+0x7d>
  }
  return fd2num(f);
  80217c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80217f:	89 04 24             	mov    %eax,(%esp)
  802182:	e8 f9 f6 ff ff       	call   801880 <fd2num>
  802187:	89 c3                	mov    %eax,%ebx
}
  802189:	89 d8                	mov    %ebx,%eax
  80218b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80218e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802191:	89 ec                	mov    %ebp,%esp
  802193:	5d                   	pop    %ebp
  802194:	c3                   	ret    
	...

008021a0 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  8021a0:	55                   	push   %ebp
  8021a1:	89 e5                	mov    %esp,%ebp
  8021a3:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  8021a6:	c7 44 24 04 58 36 80 	movl   $0x803658,0x4(%esp)
  8021ad:	00 
  8021ae:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021b1:	89 04 24             	mov    %eax,(%esp)
  8021b4:	e8 71 e9 ff ff       	call   800b2a <strcpy>
	return 0;
}
  8021b9:	b8 00 00 00 00       	mov    $0x0,%eax
  8021be:	c9                   	leave  
  8021bf:	c3                   	ret    

008021c0 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  8021c0:	55                   	push   %ebp
  8021c1:	89 e5                	mov    %esp,%ebp
  8021c3:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  8021c6:	8b 45 08             	mov    0x8(%ebp),%eax
  8021c9:	8b 40 0c             	mov    0xc(%eax),%eax
  8021cc:	89 04 24             	mov    %eax,(%esp)
  8021cf:	e8 9d 02 00 00       	call   802471 <nsipc_close>
}
  8021d4:	c9                   	leave  
  8021d5:	c3                   	ret    

008021d6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8021d6:	55                   	push   %ebp
  8021d7:	89 e5                	mov    %esp,%ebp
  8021d9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8021dc:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8021e3:	00 
  8021e4:	8b 45 10             	mov    0x10(%ebp),%eax
  8021e7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8021eb:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021ee:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021f2:	8b 45 08             	mov    0x8(%ebp),%eax
  8021f5:	8b 40 0c             	mov    0xc(%eax),%eax
  8021f8:	89 04 24             	mov    %eax,(%esp)
  8021fb:	e8 ad 02 00 00       	call   8024ad <nsipc_send>
}
  802200:	c9                   	leave  
  802201:	c3                   	ret    

00802202 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  802202:	55                   	push   %ebp
  802203:	89 e5                	mov    %esp,%ebp
  802205:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  802208:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80220f:	00 
  802210:	8b 45 10             	mov    0x10(%ebp),%eax
  802213:	89 44 24 08          	mov    %eax,0x8(%esp)
  802217:	8b 45 0c             	mov    0xc(%ebp),%eax
  80221a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80221e:	8b 45 08             	mov    0x8(%ebp),%eax
  802221:	8b 40 0c             	mov    0xc(%eax),%eax
  802224:	89 04 24             	mov    %eax,(%esp)
  802227:	e8 f4 02 00 00       	call   802520 <nsipc_recv>
}
  80222c:	c9                   	leave  
  80222d:	c3                   	ret    

0080222e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  80222e:	55                   	push   %ebp
  80222f:	89 e5                	mov    %esp,%ebp
  802231:	56                   	push   %esi
  802232:	53                   	push   %ebx
  802233:	83 ec 20             	sub    $0x20,%esp
  802236:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802238:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80223b:	89 04 24             	mov    %eax,(%esp)
  80223e:	e8 68 f6 ff ff       	call   8018ab <fd_alloc>
  802243:	89 c3                	mov    %eax,%ebx
  802245:	85 c0                	test   %eax,%eax
  802247:	78 21                	js     80226a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  802249:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802250:	00 
  802251:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802254:	89 44 24 04          	mov    %eax,0x4(%esp)
  802258:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80225f:	e8 22 f0 ff ff       	call   801286 <sys_page_alloc>
  802264:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802266:	85 c0                	test   %eax,%eax
  802268:	79 0a                	jns    802274 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  80226a:	89 34 24             	mov    %esi,(%esp)
  80226d:	e8 ff 01 00 00       	call   802471 <nsipc_close>
		return r;
  802272:	eb 28                	jmp    80229c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  802274:	8b 15 20 70 80 00    	mov    0x807020,%edx
  80227a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80227d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  80227f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802282:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  802289:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80228c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  80228f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802292:	89 04 24             	mov    %eax,(%esp)
  802295:	e8 e6 f5 ff ff       	call   801880 <fd2num>
  80229a:	89 c3                	mov    %eax,%ebx
}
  80229c:	89 d8                	mov    %ebx,%eax
  80229e:	83 c4 20             	add    $0x20,%esp
  8022a1:	5b                   	pop    %ebx
  8022a2:	5e                   	pop    %esi
  8022a3:	5d                   	pop    %ebp
  8022a4:	c3                   	ret    

008022a5 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  8022a5:	55                   	push   %ebp
  8022a6:	89 e5                	mov    %esp,%ebp
  8022a8:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  8022ab:	8b 45 10             	mov    0x10(%ebp),%eax
  8022ae:	89 44 24 08          	mov    %eax,0x8(%esp)
  8022b2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8022b5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8022b9:	8b 45 08             	mov    0x8(%ebp),%eax
  8022bc:	89 04 24             	mov    %eax,(%esp)
  8022bf:	e8 61 01 00 00       	call   802425 <nsipc_socket>
  8022c4:	85 c0                	test   %eax,%eax
  8022c6:	78 05                	js     8022cd <socket+0x28>
		return r;
	return alloc_sockfd(r);
  8022c8:	e8 61 ff ff ff       	call   80222e <alloc_sockfd>
}
  8022cd:	c9                   	leave  
  8022ce:	66 90                	xchg   %ax,%ax
  8022d0:	c3                   	ret    

008022d1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  8022d1:	55                   	push   %ebp
  8022d2:	89 e5                	mov    %esp,%ebp
  8022d4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  8022d7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  8022da:	89 54 24 04          	mov    %edx,0x4(%esp)
  8022de:	89 04 24             	mov    %eax,(%esp)
  8022e1:	e8 37 f6 ff ff       	call   80191d <fd_lookup>
  8022e6:	85 c0                	test   %eax,%eax
  8022e8:	78 15                	js     8022ff <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  8022ea:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8022ed:	8b 0a                	mov    (%edx),%ecx
  8022ef:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8022f4:	3b 0d 20 70 80 00    	cmp    0x807020,%ecx
  8022fa:	75 03                	jne    8022ff <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  8022fc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  8022ff:	c9                   	leave  
  802300:	c3                   	ret    

00802301 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  802301:	55                   	push   %ebp
  802302:	89 e5                	mov    %esp,%ebp
  802304:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802307:	8b 45 08             	mov    0x8(%ebp),%eax
  80230a:	e8 c2 ff ff ff       	call   8022d1 <fd2sockid>
  80230f:	85 c0                	test   %eax,%eax
  802311:	78 0f                	js     802322 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  802313:	8b 55 0c             	mov    0xc(%ebp),%edx
  802316:	89 54 24 04          	mov    %edx,0x4(%esp)
  80231a:	89 04 24             	mov    %eax,(%esp)
  80231d:	e8 2d 01 00 00       	call   80244f <nsipc_listen>
}
  802322:	c9                   	leave  
  802323:	c3                   	ret    

00802324 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802324:	55                   	push   %ebp
  802325:	89 e5                	mov    %esp,%ebp
  802327:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  80232a:	8b 45 08             	mov    0x8(%ebp),%eax
  80232d:	e8 9f ff ff ff       	call   8022d1 <fd2sockid>
  802332:	85 c0                	test   %eax,%eax
  802334:	78 16                	js     80234c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  802336:	8b 55 10             	mov    0x10(%ebp),%edx
  802339:	89 54 24 08          	mov    %edx,0x8(%esp)
  80233d:	8b 55 0c             	mov    0xc(%ebp),%edx
  802340:	89 54 24 04          	mov    %edx,0x4(%esp)
  802344:	89 04 24             	mov    %eax,(%esp)
  802347:	e8 54 02 00 00       	call   8025a0 <nsipc_connect>
}
  80234c:	c9                   	leave  
  80234d:	c3                   	ret    

0080234e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80234e:	55                   	push   %ebp
  80234f:	89 e5                	mov    %esp,%ebp
  802351:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802354:	8b 45 08             	mov    0x8(%ebp),%eax
  802357:	e8 75 ff ff ff       	call   8022d1 <fd2sockid>
  80235c:	85 c0                	test   %eax,%eax
  80235e:	78 0f                	js     80236f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802360:	8b 55 0c             	mov    0xc(%ebp),%edx
  802363:	89 54 24 04          	mov    %edx,0x4(%esp)
  802367:	89 04 24             	mov    %eax,(%esp)
  80236a:	e8 1c 01 00 00       	call   80248b <nsipc_shutdown>
}
  80236f:	c9                   	leave  
  802370:	c3                   	ret    

00802371 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802371:	55                   	push   %ebp
  802372:	89 e5                	mov    %esp,%ebp
  802374:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802377:	8b 45 08             	mov    0x8(%ebp),%eax
  80237a:	e8 52 ff ff ff       	call   8022d1 <fd2sockid>
  80237f:	85 c0                	test   %eax,%eax
  802381:	78 16                	js     802399 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  802383:	8b 55 10             	mov    0x10(%ebp),%edx
  802386:	89 54 24 08          	mov    %edx,0x8(%esp)
  80238a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80238d:	89 54 24 04          	mov    %edx,0x4(%esp)
  802391:	89 04 24             	mov    %eax,(%esp)
  802394:	e8 46 02 00 00       	call   8025df <nsipc_bind>
}
  802399:	c9                   	leave  
  80239a:	c3                   	ret    

0080239b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80239b:	55                   	push   %ebp
  80239c:	89 e5                	mov    %esp,%ebp
  80239e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8023a1:	8b 45 08             	mov    0x8(%ebp),%eax
  8023a4:	e8 28 ff ff ff       	call   8022d1 <fd2sockid>
  8023a9:	85 c0                	test   %eax,%eax
  8023ab:	78 1f                	js     8023cc <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  8023ad:	8b 55 10             	mov    0x10(%ebp),%edx
  8023b0:	89 54 24 08          	mov    %edx,0x8(%esp)
  8023b4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8023b7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8023bb:	89 04 24             	mov    %eax,(%esp)
  8023be:	e8 5b 02 00 00       	call   80261e <nsipc_accept>
  8023c3:	85 c0                	test   %eax,%eax
  8023c5:	78 05                	js     8023cc <accept+0x31>
		return r;
	return alloc_sockfd(r);
  8023c7:	e8 62 fe ff ff       	call   80222e <alloc_sockfd>
}
  8023cc:	c9                   	leave  
  8023cd:	8d 76 00             	lea    0x0(%esi),%esi
  8023d0:	c3                   	ret    
	...

008023e0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  8023e0:	55                   	push   %ebp
  8023e1:	89 e5                	mov    %esp,%ebp
  8023e3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  8023e6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  8023ec:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8023f3:	00 
  8023f4:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  8023fb:	00 
  8023fc:	89 44 24 04          	mov    %eax,0x4(%esp)
  802400:	89 14 24             	mov    %edx,(%esp)
  802403:	e8 a8 f3 ff ff       	call   8017b0 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  802408:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80240f:	00 
  802410:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802417:	00 
  802418:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80241b:	89 04 24             	mov    %eax,(%esp)
  80241e:	e8 ff f3 ff ff       	call   801822 <ipc_recv>
    return r;
}
  802423:	c9                   	leave  
  802424:	c3                   	ret    

00802425 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  802425:	55                   	push   %ebp
  802426:	89 e5                	mov    %esp,%ebp
  802428:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  80242b:	8b 45 08             	mov    0x8(%ebp),%eax
  80242e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  802433:	8b 45 0c             	mov    0xc(%ebp),%eax
  802436:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  80243b:	8b 45 10             	mov    0x10(%ebp),%eax
  80243e:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  802443:	b8 09 00 00 00       	mov    $0x9,%eax
  802448:	e8 93 ff ff ff       	call   8023e0 <nsipc>
}
  80244d:	c9                   	leave  
  80244e:	c3                   	ret    

0080244f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80244f:	55                   	push   %ebp
  802450:	89 e5                	mov    %esp,%ebp
  802452:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  802455:	8b 45 08             	mov    0x8(%ebp),%eax
  802458:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  80245d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802460:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802465:	b8 06 00 00 00       	mov    $0x6,%eax
  80246a:	e8 71 ff ff ff       	call   8023e0 <nsipc>
}
  80246f:	c9                   	leave  
  802470:	c3                   	ret    

00802471 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802471:	55                   	push   %ebp
  802472:	89 e5                	mov    %esp,%ebp
  802474:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802477:	8b 45 08             	mov    0x8(%ebp),%eax
  80247a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  80247f:	b8 04 00 00 00       	mov    $0x4,%eax
  802484:	e8 57 ff ff ff       	call   8023e0 <nsipc>
}
  802489:	c9                   	leave  
  80248a:	c3                   	ret    

0080248b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  80248b:	55                   	push   %ebp
  80248c:	89 e5                	mov    %esp,%ebp
  80248e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  802491:	8b 45 08             	mov    0x8(%ebp),%eax
  802494:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  802499:	8b 45 0c             	mov    0xc(%ebp),%eax
  80249c:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  8024a1:	b8 03 00 00 00       	mov    $0x3,%eax
  8024a6:	e8 35 ff ff ff       	call   8023e0 <nsipc>
}
  8024ab:	c9                   	leave  
  8024ac:	c3                   	ret    

008024ad <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  8024ad:	55                   	push   %ebp
  8024ae:	89 e5                	mov    %esp,%ebp
  8024b0:	53                   	push   %ebx
  8024b1:	83 ec 14             	sub    $0x14,%esp
  8024b4:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  8024b7:	8b 45 08             	mov    0x8(%ebp),%eax
  8024ba:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  8024bf:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  8024c5:	7e 24                	jle    8024eb <nsipc_send+0x3e>
  8024c7:	c7 44 24 0c 64 36 80 	movl   $0x803664,0xc(%esp)
  8024ce:	00 
  8024cf:	c7 44 24 08 70 36 80 	movl   $0x803670,0x8(%esp)
  8024d6:	00 
  8024d7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  8024de:	00 
  8024df:	c7 04 24 85 36 80 00 	movl   $0x803685,(%esp)
  8024e6:	e8 b1 de ff ff       	call   80039c <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  8024eb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8024ef:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024f2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024f6:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  8024fd:	e8 e3 e7 ff ff       	call   800ce5 <memmove>
	nsipcbuf.send.req_size = size;
  802502:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  802508:	8b 45 14             	mov    0x14(%ebp),%eax
  80250b:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  802510:	b8 08 00 00 00       	mov    $0x8,%eax
  802515:	e8 c6 fe ff ff       	call   8023e0 <nsipc>
}
  80251a:	83 c4 14             	add    $0x14,%esp
  80251d:	5b                   	pop    %ebx
  80251e:	5d                   	pop    %ebp
  80251f:	c3                   	ret    

00802520 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  802520:	55                   	push   %ebp
  802521:	89 e5                	mov    %esp,%ebp
  802523:	56                   	push   %esi
  802524:	53                   	push   %ebx
  802525:	83 ec 10             	sub    $0x10,%esp
  802528:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  80252b:	8b 45 08             	mov    0x8(%ebp),%eax
  80252e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  802533:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  802539:	8b 45 14             	mov    0x14(%ebp),%eax
  80253c:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802541:	b8 07 00 00 00       	mov    $0x7,%eax
  802546:	e8 95 fe ff ff       	call   8023e0 <nsipc>
  80254b:	89 c3                	mov    %eax,%ebx
  80254d:	85 c0                	test   %eax,%eax
  80254f:	78 46                	js     802597 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802551:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802556:	7f 04                	jg     80255c <nsipc_recv+0x3c>
  802558:	39 c6                	cmp    %eax,%esi
  80255a:	7d 24                	jge    802580 <nsipc_recv+0x60>
  80255c:	c7 44 24 0c 91 36 80 	movl   $0x803691,0xc(%esp)
  802563:	00 
  802564:	c7 44 24 08 70 36 80 	movl   $0x803670,0x8(%esp)
  80256b:	00 
  80256c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802573:	00 
  802574:	c7 04 24 85 36 80 00 	movl   $0x803685,(%esp)
  80257b:	e8 1c de ff ff       	call   80039c <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802580:	89 44 24 08          	mov    %eax,0x8(%esp)
  802584:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  80258b:	00 
  80258c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80258f:	89 04 24             	mov    %eax,(%esp)
  802592:	e8 4e e7 ff ff       	call   800ce5 <memmove>
	}

	return r;
}
  802597:	89 d8                	mov    %ebx,%eax
  802599:	83 c4 10             	add    $0x10,%esp
  80259c:	5b                   	pop    %ebx
  80259d:	5e                   	pop    %esi
  80259e:	5d                   	pop    %ebp
  80259f:	c3                   	ret    

008025a0 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8025a0:	55                   	push   %ebp
  8025a1:	89 e5                	mov    %esp,%ebp
  8025a3:	53                   	push   %ebx
  8025a4:	83 ec 14             	sub    $0x14,%esp
  8025a7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  8025aa:	8b 45 08             	mov    0x8(%ebp),%eax
  8025ad:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  8025b2:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8025b6:	8b 45 0c             	mov    0xc(%ebp),%eax
  8025b9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025bd:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8025c4:	e8 1c e7 ff ff       	call   800ce5 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  8025c9:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  8025cf:	b8 05 00 00 00       	mov    $0x5,%eax
  8025d4:	e8 07 fe ff ff       	call   8023e0 <nsipc>
}
  8025d9:	83 c4 14             	add    $0x14,%esp
  8025dc:	5b                   	pop    %ebx
  8025dd:	5d                   	pop    %ebp
  8025de:	c3                   	ret    

008025df <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8025df:	55                   	push   %ebp
  8025e0:	89 e5                	mov    %esp,%ebp
  8025e2:	53                   	push   %ebx
  8025e3:	83 ec 14             	sub    $0x14,%esp
  8025e6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  8025e9:	8b 45 08             	mov    0x8(%ebp),%eax
  8025ec:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8025f1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8025f5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8025f8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025fc:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802603:	e8 dd e6 ff ff       	call   800ce5 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  802608:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  80260e:	b8 02 00 00 00       	mov    $0x2,%eax
  802613:	e8 c8 fd ff ff       	call   8023e0 <nsipc>
}
  802618:	83 c4 14             	add    $0x14,%esp
  80261b:	5b                   	pop    %ebx
  80261c:	5d                   	pop    %ebp
  80261d:	c3                   	ret    

0080261e <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80261e:	55                   	push   %ebp
  80261f:	89 e5                	mov    %esp,%ebp
  802621:	83 ec 18             	sub    $0x18,%esp
  802624:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802627:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  80262a:	8b 45 08             	mov    0x8(%ebp),%eax
  80262d:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802632:	b8 01 00 00 00       	mov    $0x1,%eax
  802637:	e8 a4 fd ff ff       	call   8023e0 <nsipc>
  80263c:	89 c3                	mov    %eax,%ebx
  80263e:	85 c0                	test   %eax,%eax
  802640:	78 25                	js     802667 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802642:	be 10 60 80 00       	mov    $0x806010,%esi
  802647:	8b 06                	mov    (%esi),%eax
  802649:	89 44 24 08          	mov    %eax,0x8(%esp)
  80264d:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802654:	00 
  802655:	8b 45 0c             	mov    0xc(%ebp),%eax
  802658:	89 04 24             	mov    %eax,(%esp)
  80265b:	e8 85 e6 ff ff       	call   800ce5 <memmove>
		*addrlen = ret->ret_addrlen;
  802660:	8b 16                	mov    (%esi),%edx
  802662:	8b 45 10             	mov    0x10(%ebp),%eax
  802665:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802667:	89 d8                	mov    %ebx,%eax
  802669:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80266c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80266f:	89 ec                	mov    %ebp,%esp
  802671:	5d                   	pop    %ebp
  802672:	c3                   	ret    
	...

00802680 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802680:	55                   	push   %ebp
  802681:	89 e5                	mov    %esp,%ebp
  802683:	83 ec 18             	sub    $0x18,%esp
  802686:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802689:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80268c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80268f:	8b 45 08             	mov    0x8(%ebp),%eax
  802692:	89 04 24             	mov    %eax,(%esp)
  802695:	e8 f6 f1 ff ff       	call   801890 <fd2data>
  80269a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80269c:	c7 44 24 04 a6 36 80 	movl   $0x8036a6,0x4(%esp)
  8026a3:	00 
  8026a4:	89 34 24             	mov    %esi,(%esp)
  8026a7:	e8 7e e4 ff ff       	call   800b2a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  8026ac:	8b 43 04             	mov    0x4(%ebx),%eax
  8026af:	2b 03                	sub    (%ebx),%eax
  8026b1:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  8026b7:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  8026be:	00 00 00 
	stat->st_dev = &devpipe;
  8026c1:	c7 86 88 00 00 00 3c 	movl   $0x80703c,0x88(%esi)
  8026c8:	70 80 00 
	return 0;
}
  8026cb:	b8 00 00 00 00       	mov    $0x0,%eax
  8026d0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8026d3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8026d6:	89 ec                	mov    %ebp,%esp
  8026d8:	5d                   	pop    %ebp
  8026d9:	c3                   	ret    

008026da <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8026da:	55                   	push   %ebp
  8026db:	89 e5                	mov    %esp,%ebp
  8026dd:	53                   	push   %ebx
  8026de:	83 ec 14             	sub    $0x14,%esp
  8026e1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  8026e4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8026e8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026ef:	e8 d6 ea ff ff       	call   8011ca <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  8026f4:	89 1c 24             	mov    %ebx,(%esp)
  8026f7:	e8 94 f1 ff ff       	call   801890 <fd2data>
  8026fc:	89 44 24 04          	mov    %eax,0x4(%esp)
  802700:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802707:	e8 be ea ff ff       	call   8011ca <sys_page_unmap>
}
  80270c:	83 c4 14             	add    $0x14,%esp
  80270f:	5b                   	pop    %ebx
  802710:	5d                   	pop    %ebp
  802711:	c3                   	ret    

00802712 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  802712:	55                   	push   %ebp
  802713:	89 e5                	mov    %esp,%ebp
  802715:	57                   	push   %edi
  802716:	56                   	push   %esi
  802717:	53                   	push   %ebx
  802718:	83 ec 2c             	sub    $0x2c,%esp
  80271b:	89 c7                	mov    %eax,%edi
  80271d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  802720:	a1 78 70 80 00       	mov    0x807078,%eax
  802725:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802728:	89 3c 24             	mov    %edi,(%esp)
  80272b:	e8 7c 05 00 00       	call   802cac <pageref>
  802730:	89 c6                	mov    %eax,%esi
  802732:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802735:	89 04 24             	mov    %eax,(%esp)
  802738:	e8 6f 05 00 00       	call   802cac <pageref>
  80273d:	39 c6                	cmp    %eax,%esi
  80273f:	0f 94 c0             	sete   %al
  802742:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802745:	8b 15 78 70 80 00    	mov    0x807078,%edx
  80274b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80274e:	39 cb                	cmp    %ecx,%ebx
  802750:	75 08                	jne    80275a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802752:	83 c4 2c             	add    $0x2c,%esp
  802755:	5b                   	pop    %ebx
  802756:	5e                   	pop    %esi
  802757:	5f                   	pop    %edi
  802758:	5d                   	pop    %ebp
  802759:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80275a:	83 f8 01             	cmp    $0x1,%eax
  80275d:	75 c1                	jne    802720 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80275f:	8b 52 58             	mov    0x58(%edx),%edx
  802762:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802766:	89 54 24 08          	mov    %edx,0x8(%esp)
  80276a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80276e:	c7 04 24 ad 36 80 00 	movl   $0x8036ad,(%esp)
  802775:	e8 e7 dc ff ff       	call   800461 <cprintf>
  80277a:	eb a4                	jmp    802720 <_pipeisclosed+0xe>

0080277c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80277c:	55                   	push   %ebp
  80277d:	89 e5                	mov    %esp,%ebp
  80277f:	57                   	push   %edi
  802780:	56                   	push   %esi
  802781:	53                   	push   %ebx
  802782:	83 ec 1c             	sub    $0x1c,%esp
  802785:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802788:	89 34 24             	mov    %esi,(%esp)
  80278b:	e8 00 f1 ff ff       	call   801890 <fd2data>
  802790:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802792:	bf 00 00 00 00       	mov    $0x0,%edi
  802797:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80279b:	75 54                	jne    8027f1 <devpipe_write+0x75>
  80279d:	eb 60                	jmp    8027ff <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80279f:	89 da                	mov    %ebx,%edx
  8027a1:	89 f0                	mov    %esi,%eax
  8027a3:	e8 6a ff ff ff       	call   802712 <_pipeisclosed>
  8027a8:	85 c0                	test   %eax,%eax
  8027aa:	74 07                	je     8027b3 <devpipe_write+0x37>
  8027ac:	b8 00 00 00 00       	mov    $0x0,%eax
  8027b1:	eb 53                	jmp    802806 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  8027b3:	90                   	nop
  8027b4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8027b8:	e8 28 eb ff ff       	call   8012e5 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8027bd:	8b 43 04             	mov    0x4(%ebx),%eax
  8027c0:	8b 13                	mov    (%ebx),%edx
  8027c2:	83 c2 20             	add    $0x20,%edx
  8027c5:	39 d0                	cmp    %edx,%eax
  8027c7:	73 d6                	jae    80279f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  8027c9:	89 c2                	mov    %eax,%edx
  8027cb:	c1 fa 1f             	sar    $0x1f,%edx
  8027ce:	c1 ea 1b             	shr    $0x1b,%edx
  8027d1:	01 d0                	add    %edx,%eax
  8027d3:	83 e0 1f             	and    $0x1f,%eax
  8027d6:	29 d0                	sub    %edx,%eax
  8027d8:	89 c2                	mov    %eax,%edx
  8027da:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8027dd:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  8027e1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  8027e5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8027e9:	83 c7 01             	add    $0x1,%edi
  8027ec:	39 7d 10             	cmp    %edi,0x10(%ebp)
  8027ef:	76 13                	jbe    802804 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8027f1:	8b 43 04             	mov    0x4(%ebx),%eax
  8027f4:	8b 13                	mov    (%ebx),%edx
  8027f6:	83 c2 20             	add    $0x20,%edx
  8027f9:	39 d0                	cmp    %edx,%eax
  8027fb:	73 a2                	jae    80279f <devpipe_write+0x23>
  8027fd:	eb ca                	jmp    8027c9 <devpipe_write+0x4d>
  8027ff:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802804:	89 f8                	mov    %edi,%eax
}
  802806:	83 c4 1c             	add    $0x1c,%esp
  802809:	5b                   	pop    %ebx
  80280a:	5e                   	pop    %esi
  80280b:	5f                   	pop    %edi
  80280c:	5d                   	pop    %ebp
  80280d:	c3                   	ret    

0080280e <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  80280e:	55                   	push   %ebp
  80280f:	89 e5                	mov    %esp,%ebp
  802811:	83 ec 28             	sub    $0x28,%esp
  802814:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802817:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80281a:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80281d:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  802820:	89 3c 24             	mov    %edi,(%esp)
  802823:	e8 68 f0 ff ff       	call   801890 <fd2data>
  802828:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  80282a:	be 00 00 00 00       	mov    $0x0,%esi
  80282f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802833:	75 4c                	jne    802881 <devpipe_read+0x73>
  802835:	eb 5b                	jmp    802892 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802837:	89 f0                	mov    %esi,%eax
  802839:	eb 5e                	jmp    802899 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80283b:	89 da                	mov    %ebx,%edx
  80283d:	89 f8                	mov    %edi,%eax
  80283f:	90                   	nop
  802840:	e8 cd fe ff ff       	call   802712 <_pipeisclosed>
  802845:	85 c0                	test   %eax,%eax
  802847:	74 07                	je     802850 <devpipe_read+0x42>
  802849:	b8 00 00 00 00       	mov    $0x0,%eax
  80284e:	eb 49                	jmp    802899 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802850:	e8 90 ea ff ff       	call   8012e5 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802855:	8b 03                	mov    (%ebx),%eax
  802857:	3b 43 04             	cmp    0x4(%ebx),%eax
  80285a:	74 df                	je     80283b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80285c:	89 c2                	mov    %eax,%edx
  80285e:	c1 fa 1f             	sar    $0x1f,%edx
  802861:	c1 ea 1b             	shr    $0x1b,%edx
  802864:	01 d0                	add    %edx,%eax
  802866:	83 e0 1f             	and    $0x1f,%eax
  802869:	29 d0                	sub    %edx,%eax
  80286b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802870:	8b 55 0c             	mov    0xc(%ebp),%edx
  802873:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802876:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802879:	83 c6 01             	add    $0x1,%esi
  80287c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80287f:	76 16                	jbe    802897 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802881:	8b 03                	mov    (%ebx),%eax
  802883:	3b 43 04             	cmp    0x4(%ebx),%eax
  802886:	75 d4                	jne    80285c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802888:	85 f6                	test   %esi,%esi
  80288a:	75 ab                	jne    802837 <devpipe_read+0x29>
  80288c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802890:	eb a9                	jmp    80283b <devpipe_read+0x2d>
  802892:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802897:	89 f0                	mov    %esi,%eax
}
  802899:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80289c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80289f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8028a2:	89 ec                	mov    %ebp,%esp
  8028a4:	5d                   	pop    %ebp
  8028a5:	c3                   	ret    

008028a6 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  8028a6:	55                   	push   %ebp
  8028a7:	89 e5                	mov    %esp,%ebp
  8028a9:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8028ac:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8028af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028b3:	8b 45 08             	mov    0x8(%ebp),%eax
  8028b6:	89 04 24             	mov    %eax,(%esp)
  8028b9:	e8 5f f0 ff ff       	call   80191d <fd_lookup>
  8028be:	85 c0                	test   %eax,%eax
  8028c0:	78 15                	js     8028d7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  8028c2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8028c5:	89 04 24             	mov    %eax,(%esp)
  8028c8:	e8 c3 ef ff ff       	call   801890 <fd2data>
	return _pipeisclosed(fd, p);
  8028cd:	89 c2                	mov    %eax,%edx
  8028cf:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8028d2:	e8 3b fe ff ff       	call   802712 <_pipeisclosed>
}
  8028d7:	c9                   	leave  
  8028d8:	c3                   	ret    

008028d9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  8028d9:	55                   	push   %ebp
  8028da:	89 e5                	mov    %esp,%ebp
  8028dc:	83 ec 48             	sub    $0x48,%esp
  8028df:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8028e2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8028e5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8028e8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8028eb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8028ee:	89 04 24             	mov    %eax,(%esp)
  8028f1:	e8 b5 ef ff ff       	call   8018ab <fd_alloc>
  8028f6:	89 c3                	mov    %eax,%ebx
  8028f8:	85 c0                	test   %eax,%eax
  8028fa:	0f 88 42 01 00 00    	js     802a42 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802900:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802907:	00 
  802908:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80290b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80290f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802916:	e8 6b e9 ff ff       	call   801286 <sys_page_alloc>
  80291b:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80291d:	85 c0                	test   %eax,%eax
  80291f:	0f 88 1d 01 00 00    	js     802a42 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802925:	8d 45 e0             	lea    -0x20(%ebp),%eax
  802928:	89 04 24             	mov    %eax,(%esp)
  80292b:	e8 7b ef ff ff       	call   8018ab <fd_alloc>
  802930:	89 c3                	mov    %eax,%ebx
  802932:	85 c0                	test   %eax,%eax
  802934:	0f 88 f5 00 00 00    	js     802a2f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80293a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802941:	00 
  802942:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802945:	89 44 24 04          	mov    %eax,0x4(%esp)
  802949:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802950:	e8 31 e9 ff ff       	call   801286 <sys_page_alloc>
  802955:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802957:	85 c0                	test   %eax,%eax
  802959:	0f 88 d0 00 00 00    	js     802a2f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80295f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802962:	89 04 24             	mov    %eax,(%esp)
  802965:	e8 26 ef ff ff       	call   801890 <fd2data>
  80296a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80296c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802973:	00 
  802974:	89 44 24 04          	mov    %eax,0x4(%esp)
  802978:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80297f:	e8 02 e9 ff ff       	call   801286 <sys_page_alloc>
  802984:	89 c3                	mov    %eax,%ebx
  802986:	85 c0                	test   %eax,%eax
  802988:	0f 88 8e 00 00 00    	js     802a1c <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80298e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802991:	89 04 24             	mov    %eax,(%esp)
  802994:	e8 f7 ee ff ff       	call   801890 <fd2data>
  802999:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  8029a0:	00 
  8029a1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8029a5:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8029ac:	00 
  8029ad:	89 74 24 04          	mov    %esi,0x4(%esp)
  8029b1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8029b8:	e8 6b e8 ff ff       	call   801228 <sys_page_map>
  8029bd:	89 c3                	mov    %eax,%ebx
  8029bf:	85 c0                	test   %eax,%eax
  8029c1:	78 49                	js     802a0c <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  8029c3:	b8 3c 70 80 00       	mov    $0x80703c,%eax
  8029c8:	8b 08                	mov    (%eax),%ecx
  8029ca:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8029cd:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  8029cf:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8029d2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  8029d9:	8b 10                	mov    (%eax),%edx
  8029db:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8029de:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  8029e0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8029e3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  8029ea:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8029ed:	89 04 24             	mov    %eax,(%esp)
  8029f0:	e8 8b ee ff ff       	call   801880 <fd2num>
  8029f5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  8029f7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8029fa:	89 04 24             	mov    %eax,(%esp)
  8029fd:	e8 7e ee ff ff       	call   801880 <fd2num>
  802a02:	89 47 04             	mov    %eax,0x4(%edi)
  802a05:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  802a0a:	eb 36                	jmp    802a42 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  802a0c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802a10:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802a17:	e8 ae e7 ff ff       	call   8011ca <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  802a1c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802a1f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a23:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802a2a:	e8 9b e7 ff ff       	call   8011ca <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  802a2f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802a32:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a36:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802a3d:	e8 88 e7 ff ff       	call   8011ca <sys_page_unmap>
    err:
	return r;
}
  802a42:	89 d8                	mov    %ebx,%eax
  802a44:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802a47:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802a4a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802a4d:	89 ec                	mov    %ebp,%esp
  802a4f:	5d                   	pop    %ebp
  802a50:	c3                   	ret    
	...

00802a60 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802a60:	55                   	push   %ebp
  802a61:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802a63:	b8 00 00 00 00       	mov    $0x0,%eax
  802a68:	5d                   	pop    %ebp
  802a69:	c3                   	ret    

00802a6a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  802a6a:	55                   	push   %ebp
  802a6b:	89 e5                	mov    %esp,%ebp
  802a6d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802a70:	c7 44 24 04 c5 36 80 	movl   $0x8036c5,0x4(%esp)
  802a77:	00 
  802a78:	8b 45 0c             	mov    0xc(%ebp),%eax
  802a7b:	89 04 24             	mov    %eax,(%esp)
  802a7e:	e8 a7 e0 ff ff       	call   800b2a <strcpy>
	return 0;
}
  802a83:	b8 00 00 00 00       	mov    $0x0,%eax
  802a88:	c9                   	leave  
  802a89:	c3                   	ret    

00802a8a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  802a8a:	55                   	push   %ebp
  802a8b:	89 e5                	mov    %esp,%ebp
  802a8d:	57                   	push   %edi
  802a8e:	56                   	push   %esi
  802a8f:	53                   	push   %ebx
  802a90:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802a96:	b8 00 00 00 00       	mov    $0x0,%eax
  802a9b:	be 00 00 00 00       	mov    $0x0,%esi
  802aa0:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802aa4:	74 41                	je     802ae7 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802aa6:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  802aac:	8b 5d 10             	mov    0x10(%ebp),%ebx
  802aaf:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802ab1:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802ab7:	ba 7f 00 00 00       	mov    $0x7f,%edx
  802abc:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802abf:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802ac3:	03 45 0c             	add    0xc(%ebp),%eax
  802ac6:	89 44 24 04          	mov    %eax,0x4(%esp)
  802aca:	89 3c 24             	mov    %edi,(%esp)
  802acd:	e8 13 e2 ff ff       	call   800ce5 <memmove>
		sys_cputs(buf, m);
  802ad2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802ad6:	89 3c 24             	mov    %edi,(%esp)
  802ad9:	e8 42 e4 ff ff       	call   800f20 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802ade:	01 de                	add    %ebx,%esi
  802ae0:	89 f0                	mov    %esi,%eax
  802ae2:	3b 75 10             	cmp    0x10(%ebp),%esi
  802ae5:	72 c5                	jb     802aac <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  802ae7:	89 f0                	mov    %esi,%eax
  802ae9:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  802aef:	5b                   	pop    %ebx
  802af0:	5e                   	pop    %esi
  802af1:	5f                   	pop    %edi
  802af2:	5d                   	pop    %ebp
  802af3:	c3                   	ret    

00802af4 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  802af4:	55                   	push   %ebp
  802af5:	89 e5                	mov    %esp,%ebp
  802af7:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  802afa:	8b 45 08             	mov    0x8(%ebp),%eax
  802afd:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  802b00:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802b07:	00 
  802b08:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802b0b:	89 04 24             	mov    %eax,(%esp)
  802b0e:	e8 0d e4 ff ff       	call   800f20 <sys_cputs>
}
  802b13:	c9                   	leave  
  802b14:	c3                   	ret    

00802b15 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  802b15:	55                   	push   %ebp
  802b16:	89 e5                	mov    %esp,%ebp
  802b18:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  802b1b:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802b1f:	75 07                	jne    802b28 <devcons_read+0x13>
  802b21:	eb 2d                	jmp    802b50 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  802b23:	e8 bd e7 ff ff       	call   8012e5 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  802b28:	90                   	nop
  802b29:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802b30:	e8 b7 e3 ff ff       	call   800eec <sys_cgetc>
  802b35:	85 c0                	test   %eax,%eax
  802b37:	74 ea                	je     802b23 <devcons_read+0xe>
  802b39:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  802b3b:	85 c0                	test   %eax,%eax
  802b3d:	78 16                	js     802b55 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  802b3f:	83 f8 04             	cmp    $0x4,%eax
  802b42:	74 0c                	je     802b50 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802b44:	8b 45 0c             	mov    0xc(%ebp),%eax
  802b47:	88 10                	mov    %dl,(%eax)
  802b49:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  802b4e:	eb 05                	jmp    802b55 <devcons_read+0x40>
  802b50:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802b55:	c9                   	leave  
  802b56:	c3                   	ret    

00802b57 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802b57:	55                   	push   %ebp
  802b58:	89 e5                	mov    %esp,%ebp
  802b5a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  802b5d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802b60:	89 04 24             	mov    %eax,(%esp)
  802b63:	e8 43 ed ff ff       	call   8018ab <fd_alloc>
  802b68:	85 c0                	test   %eax,%eax
  802b6a:	78 3f                	js     802bab <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  802b6c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802b73:	00 
  802b74:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b77:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b7b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802b82:	e8 ff e6 ff ff       	call   801286 <sys_page_alloc>
  802b87:	85 c0                	test   %eax,%eax
  802b89:	78 20                	js     802bab <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  802b8b:	8b 15 58 70 80 00    	mov    0x807058,%edx
  802b91:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b94:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802b96:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b99:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802ba0:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ba3:	89 04 24             	mov    %eax,(%esp)
  802ba6:	e8 d5 ec ff ff       	call   801880 <fd2num>
}
  802bab:	c9                   	leave  
  802bac:	c3                   	ret    

00802bad <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  802bad:	55                   	push   %ebp
  802bae:	89 e5                	mov    %esp,%ebp
  802bb0:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802bb3:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802bb6:	89 44 24 04          	mov    %eax,0x4(%esp)
  802bba:	8b 45 08             	mov    0x8(%ebp),%eax
  802bbd:	89 04 24             	mov    %eax,(%esp)
  802bc0:	e8 58 ed ff ff       	call   80191d <fd_lookup>
  802bc5:	85 c0                	test   %eax,%eax
  802bc7:	78 11                	js     802bda <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802bc9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802bcc:	8b 00                	mov    (%eax),%eax
  802bce:	3b 05 58 70 80 00    	cmp    0x807058,%eax
  802bd4:	0f 94 c0             	sete   %al
  802bd7:	0f b6 c0             	movzbl %al,%eax
}
  802bda:	c9                   	leave  
  802bdb:	c3                   	ret    

00802bdc <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  802bdc:	55                   	push   %ebp
  802bdd:	89 e5                	mov    %esp,%ebp
  802bdf:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  802be2:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  802be9:	00 
  802bea:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802bed:	89 44 24 04          	mov    %eax,0x4(%esp)
  802bf1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802bf8:	e8 86 ef ff ff       	call   801b83 <read>
	if (r < 0)
  802bfd:	85 c0                	test   %eax,%eax
  802bff:	78 0f                	js     802c10 <getchar+0x34>
		return r;
	if (r < 1)
  802c01:	85 c0                	test   %eax,%eax
  802c03:	7f 07                	jg     802c0c <getchar+0x30>
  802c05:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  802c0a:	eb 04                	jmp    802c10 <getchar+0x34>
		return -E_EOF;
	return c;
  802c0c:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  802c10:	c9                   	leave  
  802c11:	c3                   	ret    
	...

00802c14 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802c14:	55                   	push   %ebp
  802c15:	89 e5                	mov    %esp,%ebp
  802c17:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  802c1a:	83 3d 80 70 80 00 00 	cmpl   $0x0,0x807080
  802c21:	75 55                	jne    802c78 <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  802c23:	e8 f1 e6 ff ff       	call   801319 <sys_getenvid>
  802c28:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802c2f:	00 
  802c30:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  802c37:	ee 
  802c38:	89 04 24             	mov    %eax,(%esp)
  802c3b:	e8 46 e6 ff ff       	call   801286 <sys_page_alloc>
  802c40:	85 c0                	test   %eax,%eax
  802c42:	74 1c                	je     802c60 <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  802c44:	c7 44 24 08 d4 36 80 	movl   $0x8036d4,0x8(%esp)
  802c4b:	00 
  802c4c:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  802c53:	00 
  802c54:	c7 04 24 f8 36 80 00 	movl   $0x8036f8,(%esp)
  802c5b:	e8 3c d7 ff ff       	call   80039c <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  802c60:	a1 78 70 80 00       	mov    0x807078,%eax
  802c65:	8b 40 4c             	mov    0x4c(%eax),%eax
  802c68:	c7 44 24 04 84 2c 80 	movl   $0x802c84,0x4(%esp)
  802c6f:	00 
  802c70:	89 04 24             	mov    %eax,(%esp)
  802c73:	e8 38 e4 ff ff       	call   8010b0 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802c78:	8b 45 08             	mov    0x8(%ebp),%eax
  802c7b:	a3 80 70 80 00       	mov    %eax,0x807080
}
  802c80:	c9                   	leave  
  802c81:	c3                   	ret    
	...

00802c84 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  802c84:	54                   	push   %esp
	movl _pgfault_handler, %eax
  802c85:	a1 80 70 80 00       	mov    0x807080,%eax
	call *%eax
  802c8a:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  802c8c:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  802c8f:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  802c94:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  802c98:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  802c9c:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  802c9e:	83 c4 08             	add    $0x8,%esp
    popal
  802ca1:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  802ca2:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  802ca6:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  802ca7:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  802cab:	c3                   	ret    

00802cac <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802cac:	55                   	push   %ebp
  802cad:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  802caf:	8b 45 08             	mov    0x8(%ebp),%eax
  802cb2:	89 c2                	mov    %eax,%edx
  802cb4:	c1 ea 16             	shr    $0x16,%edx
  802cb7:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  802cbe:	f6 c2 01             	test   $0x1,%dl
  802cc1:	74 26                	je     802ce9 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  802cc3:	c1 e8 0c             	shr    $0xc,%eax
  802cc6:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802ccd:	a8 01                	test   $0x1,%al
  802ccf:	74 18                	je     802ce9 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802cd1:	c1 e8 0c             	shr    $0xc,%eax
  802cd4:	8d 14 40             	lea    (%eax,%eax,2),%edx
  802cd7:	c1 e2 02             	shl    $0x2,%edx
  802cda:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802cdf:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  802ce4:	0f b7 c0             	movzwl %ax,%eax
  802ce7:	eb 05                	jmp    802cee <pageref+0x42>
  802ce9:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802cee:	5d                   	pop    %ebp
  802cef:	c3                   	ret    

00802cf0 <__udivdi3>:
  802cf0:	55                   	push   %ebp
  802cf1:	89 e5                	mov    %esp,%ebp
  802cf3:	57                   	push   %edi
  802cf4:	56                   	push   %esi
  802cf5:	83 ec 10             	sub    $0x10,%esp
  802cf8:	8b 45 14             	mov    0x14(%ebp),%eax
  802cfb:	8b 55 08             	mov    0x8(%ebp),%edx
  802cfe:	8b 75 10             	mov    0x10(%ebp),%esi
  802d01:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802d04:	85 c0                	test   %eax,%eax
  802d06:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802d09:	75 35                	jne    802d40 <__udivdi3+0x50>
  802d0b:	39 fe                	cmp    %edi,%esi
  802d0d:	77 61                	ja     802d70 <__udivdi3+0x80>
  802d0f:	85 f6                	test   %esi,%esi
  802d11:	75 0b                	jne    802d1e <__udivdi3+0x2e>
  802d13:	b8 01 00 00 00       	mov    $0x1,%eax
  802d18:	31 d2                	xor    %edx,%edx
  802d1a:	f7 f6                	div    %esi
  802d1c:	89 c6                	mov    %eax,%esi
  802d1e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802d21:	31 d2                	xor    %edx,%edx
  802d23:	89 f8                	mov    %edi,%eax
  802d25:	f7 f6                	div    %esi
  802d27:	89 c7                	mov    %eax,%edi
  802d29:	89 c8                	mov    %ecx,%eax
  802d2b:	f7 f6                	div    %esi
  802d2d:	89 c1                	mov    %eax,%ecx
  802d2f:	89 fa                	mov    %edi,%edx
  802d31:	89 c8                	mov    %ecx,%eax
  802d33:	83 c4 10             	add    $0x10,%esp
  802d36:	5e                   	pop    %esi
  802d37:	5f                   	pop    %edi
  802d38:	5d                   	pop    %ebp
  802d39:	c3                   	ret    
  802d3a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802d40:	39 f8                	cmp    %edi,%eax
  802d42:	77 1c                	ja     802d60 <__udivdi3+0x70>
  802d44:	0f bd d0             	bsr    %eax,%edx
  802d47:	83 f2 1f             	xor    $0x1f,%edx
  802d4a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802d4d:	75 39                	jne    802d88 <__udivdi3+0x98>
  802d4f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802d52:	0f 86 a0 00 00 00    	jbe    802df8 <__udivdi3+0x108>
  802d58:	39 f8                	cmp    %edi,%eax
  802d5a:	0f 82 98 00 00 00    	jb     802df8 <__udivdi3+0x108>
  802d60:	31 ff                	xor    %edi,%edi
  802d62:	31 c9                	xor    %ecx,%ecx
  802d64:	89 c8                	mov    %ecx,%eax
  802d66:	89 fa                	mov    %edi,%edx
  802d68:	83 c4 10             	add    $0x10,%esp
  802d6b:	5e                   	pop    %esi
  802d6c:	5f                   	pop    %edi
  802d6d:	5d                   	pop    %ebp
  802d6e:	c3                   	ret    
  802d6f:	90                   	nop
  802d70:	89 d1                	mov    %edx,%ecx
  802d72:	89 fa                	mov    %edi,%edx
  802d74:	89 c8                	mov    %ecx,%eax
  802d76:	31 ff                	xor    %edi,%edi
  802d78:	f7 f6                	div    %esi
  802d7a:	89 c1                	mov    %eax,%ecx
  802d7c:	89 fa                	mov    %edi,%edx
  802d7e:	89 c8                	mov    %ecx,%eax
  802d80:	83 c4 10             	add    $0x10,%esp
  802d83:	5e                   	pop    %esi
  802d84:	5f                   	pop    %edi
  802d85:	5d                   	pop    %ebp
  802d86:	c3                   	ret    
  802d87:	90                   	nop
  802d88:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802d8c:	89 f2                	mov    %esi,%edx
  802d8e:	d3 e0                	shl    %cl,%eax
  802d90:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802d93:	b8 20 00 00 00       	mov    $0x20,%eax
  802d98:	2b 45 f4             	sub    -0xc(%ebp),%eax
  802d9b:	89 c1                	mov    %eax,%ecx
  802d9d:	d3 ea                	shr    %cl,%edx
  802d9f:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802da3:	0b 55 ec             	or     -0x14(%ebp),%edx
  802da6:	d3 e6                	shl    %cl,%esi
  802da8:	89 c1                	mov    %eax,%ecx
  802daa:	89 75 e8             	mov    %esi,-0x18(%ebp)
  802dad:	89 fe                	mov    %edi,%esi
  802daf:	d3 ee                	shr    %cl,%esi
  802db1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802db5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802db8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802dbb:	d3 e7                	shl    %cl,%edi
  802dbd:	89 c1                	mov    %eax,%ecx
  802dbf:	d3 ea                	shr    %cl,%edx
  802dc1:	09 d7                	or     %edx,%edi
  802dc3:	89 f2                	mov    %esi,%edx
  802dc5:	89 f8                	mov    %edi,%eax
  802dc7:	f7 75 ec             	divl   -0x14(%ebp)
  802dca:	89 d6                	mov    %edx,%esi
  802dcc:	89 c7                	mov    %eax,%edi
  802dce:	f7 65 e8             	mull   -0x18(%ebp)
  802dd1:	39 d6                	cmp    %edx,%esi
  802dd3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802dd6:	72 30                	jb     802e08 <__udivdi3+0x118>
  802dd8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802ddb:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802ddf:	d3 e2                	shl    %cl,%edx
  802de1:	39 c2                	cmp    %eax,%edx
  802de3:	73 05                	jae    802dea <__udivdi3+0xfa>
  802de5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802de8:	74 1e                	je     802e08 <__udivdi3+0x118>
  802dea:	89 f9                	mov    %edi,%ecx
  802dec:	31 ff                	xor    %edi,%edi
  802dee:	e9 71 ff ff ff       	jmp    802d64 <__udivdi3+0x74>
  802df3:	90                   	nop
  802df4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802df8:	31 ff                	xor    %edi,%edi
  802dfa:	b9 01 00 00 00       	mov    $0x1,%ecx
  802dff:	e9 60 ff ff ff       	jmp    802d64 <__udivdi3+0x74>
  802e04:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802e08:	8d 4f ff             	lea    -0x1(%edi),%ecx
  802e0b:	31 ff                	xor    %edi,%edi
  802e0d:	89 c8                	mov    %ecx,%eax
  802e0f:	89 fa                	mov    %edi,%edx
  802e11:	83 c4 10             	add    $0x10,%esp
  802e14:	5e                   	pop    %esi
  802e15:	5f                   	pop    %edi
  802e16:	5d                   	pop    %ebp
  802e17:	c3                   	ret    
	...

00802e20 <__umoddi3>:
  802e20:	55                   	push   %ebp
  802e21:	89 e5                	mov    %esp,%ebp
  802e23:	57                   	push   %edi
  802e24:	56                   	push   %esi
  802e25:	83 ec 20             	sub    $0x20,%esp
  802e28:	8b 55 14             	mov    0x14(%ebp),%edx
  802e2b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802e2e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802e31:	8b 75 0c             	mov    0xc(%ebp),%esi
  802e34:	85 d2                	test   %edx,%edx
  802e36:	89 c8                	mov    %ecx,%eax
  802e38:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  802e3b:	75 13                	jne    802e50 <__umoddi3+0x30>
  802e3d:	39 f7                	cmp    %esi,%edi
  802e3f:	76 3f                	jbe    802e80 <__umoddi3+0x60>
  802e41:	89 f2                	mov    %esi,%edx
  802e43:	f7 f7                	div    %edi
  802e45:	89 d0                	mov    %edx,%eax
  802e47:	31 d2                	xor    %edx,%edx
  802e49:	83 c4 20             	add    $0x20,%esp
  802e4c:	5e                   	pop    %esi
  802e4d:	5f                   	pop    %edi
  802e4e:	5d                   	pop    %ebp
  802e4f:	c3                   	ret    
  802e50:	39 f2                	cmp    %esi,%edx
  802e52:	77 4c                	ja     802ea0 <__umoddi3+0x80>
  802e54:	0f bd ca             	bsr    %edx,%ecx
  802e57:	83 f1 1f             	xor    $0x1f,%ecx
  802e5a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  802e5d:	75 51                	jne    802eb0 <__umoddi3+0x90>
  802e5f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802e62:	0f 87 e0 00 00 00    	ja     802f48 <__umoddi3+0x128>
  802e68:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e6b:	29 f8                	sub    %edi,%eax
  802e6d:	19 d6                	sbb    %edx,%esi
  802e6f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802e72:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e75:	89 f2                	mov    %esi,%edx
  802e77:	83 c4 20             	add    $0x20,%esp
  802e7a:	5e                   	pop    %esi
  802e7b:	5f                   	pop    %edi
  802e7c:	5d                   	pop    %ebp
  802e7d:	c3                   	ret    
  802e7e:	66 90                	xchg   %ax,%ax
  802e80:	85 ff                	test   %edi,%edi
  802e82:	75 0b                	jne    802e8f <__umoddi3+0x6f>
  802e84:	b8 01 00 00 00       	mov    $0x1,%eax
  802e89:	31 d2                	xor    %edx,%edx
  802e8b:	f7 f7                	div    %edi
  802e8d:	89 c7                	mov    %eax,%edi
  802e8f:	89 f0                	mov    %esi,%eax
  802e91:	31 d2                	xor    %edx,%edx
  802e93:	f7 f7                	div    %edi
  802e95:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e98:	f7 f7                	div    %edi
  802e9a:	eb a9                	jmp    802e45 <__umoddi3+0x25>
  802e9c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802ea0:	89 c8                	mov    %ecx,%eax
  802ea2:	89 f2                	mov    %esi,%edx
  802ea4:	83 c4 20             	add    $0x20,%esp
  802ea7:	5e                   	pop    %esi
  802ea8:	5f                   	pop    %edi
  802ea9:	5d                   	pop    %ebp
  802eaa:	c3                   	ret    
  802eab:	90                   	nop
  802eac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802eb0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802eb4:	d3 e2                	shl    %cl,%edx
  802eb6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802eb9:	ba 20 00 00 00       	mov    $0x20,%edx
  802ebe:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802ec1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802ec4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ec8:	89 fa                	mov    %edi,%edx
  802eca:	d3 ea                	shr    %cl,%edx
  802ecc:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802ed0:	0b 55 f4             	or     -0xc(%ebp),%edx
  802ed3:	d3 e7                	shl    %cl,%edi
  802ed5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ed9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802edc:	89 f2                	mov    %esi,%edx
  802ede:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802ee1:	89 c7                	mov    %eax,%edi
  802ee3:	d3 ea                	shr    %cl,%edx
  802ee5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802ee9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802eec:	89 c2                	mov    %eax,%edx
  802eee:	d3 e6                	shl    %cl,%esi
  802ef0:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ef4:	d3 ea                	shr    %cl,%edx
  802ef6:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802efa:	09 d6                	or     %edx,%esi
  802efc:	89 f0                	mov    %esi,%eax
  802efe:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802f01:	d3 e7                	shl    %cl,%edi
  802f03:	89 f2                	mov    %esi,%edx
  802f05:	f7 75 f4             	divl   -0xc(%ebp)
  802f08:	89 d6                	mov    %edx,%esi
  802f0a:	f7 65 e8             	mull   -0x18(%ebp)
  802f0d:	39 d6                	cmp    %edx,%esi
  802f0f:	72 2b                	jb     802f3c <__umoddi3+0x11c>
  802f11:	39 c7                	cmp    %eax,%edi
  802f13:	72 23                	jb     802f38 <__umoddi3+0x118>
  802f15:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802f19:	29 c7                	sub    %eax,%edi
  802f1b:	19 d6                	sbb    %edx,%esi
  802f1d:	89 f0                	mov    %esi,%eax
  802f1f:	89 f2                	mov    %esi,%edx
  802f21:	d3 ef                	shr    %cl,%edi
  802f23:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802f27:	d3 e0                	shl    %cl,%eax
  802f29:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802f2d:	09 f8                	or     %edi,%eax
  802f2f:	d3 ea                	shr    %cl,%edx
  802f31:	83 c4 20             	add    $0x20,%esp
  802f34:	5e                   	pop    %esi
  802f35:	5f                   	pop    %edi
  802f36:	5d                   	pop    %ebp
  802f37:	c3                   	ret    
  802f38:	39 d6                	cmp    %edx,%esi
  802f3a:	75 d9                	jne    802f15 <__umoddi3+0xf5>
  802f3c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802f3f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802f42:	eb d1                	jmp    802f15 <__umoddi3+0xf5>
  802f44:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802f48:	39 f2                	cmp    %esi,%edx
  802f4a:	0f 82 18 ff ff ff    	jb     802e68 <__umoddi3+0x48>
  802f50:	e9 1d ff ff ff       	jmp    802e72 <__umoddi3+0x52>
